notifyDataSetChanged example

后端 未结 5 921
再見小時候
再見小時候 2020-11-21 07:28

I\'m trying to use in my Android Application the notifyDataSetChanged() method for an ArrayAdapter but it doesn\'t work for me.

5条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-21 08:00

    You can use the runOnUiThread() method as follows. If you're not using a ListActivity, just adapt the code to get a reference to your ArrayAdapter.

    final ArrayAdapter adapter = ((ArrayAdapter)getListAdapter());
    runOnUiThread(new Runnable() {
        public void run() {
            adapter.notifyDataSetChanged();
        }
    });
    

提交回复
热议问题