Update Android ListActivity when list data changes?

前端 未结 3 970
栀梦
栀梦 2021-02-04 07:32

I wanted to know how to refresh a ListActivity when I change/add data to it.

I first thought that ListAdapter would know when the list is chang

相关标签:
3条回答
  • 2021-02-04 07:55

    Maybe you should do this setListAdapter(listAdapter);

    0 讨论(0)
  • 2021-02-04 07:59

    Try ArrayAdapter:notifyDataSetChanged
    Google docs link

    0 讨论(0)
  • 2021-02-04 08:03

    If you are using an ArrayAdapter, manipulate the contents of the list through the adapter -- do not touch the underlying list. There are add(), insert(), and remove() methods on ArrayAdapter.

    If you are using a CursorAdapter, run a requery() on the Cursor.

    0 讨论(0)
提交回复
热议问题