How do I get notifyDatasetChanged() to work with a ListAdapter?

前端 未结 2 2057
醉话见心
醉话见心 2021-01-13 01:27

Right now I use setAdapter to update my ListView, but I think the proper way is to use notifiyDatasetChanged() and I can\'t get that to work in my main class (it\'s in the a

2条回答
  •  攒了一身酷
    2021-01-13 01:38

    Dont call the notifyDataSetChanged(); method while creation.

    only call it when content of your listViewScore changes.. and to use it at that time-

    replace

    listView.getAdapter().notifyDatasetChanged();
    

    with

    ((ScoreListAdapter)listView.getAdapter()).notifyDataSetChanged();
    

    and see the magic...

    thanks.

提交回复
热议问题