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 changes, but when I have added elements to the list there is no update on the ListActivity
, only when I close the ListActivity and reopen it again I see the changes occur.
So I searched for any method such as: update(), refesh()
or something like that, but there is none. It seems I haven't gotten the concept, can someone help me please?
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
.
Try ArrayAdapter:notifyDataSetChanged
Google docs link
也许你应该这样做setListAdapter(listAdapter);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.