Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

Try ArrayAdapter:notifyDataSetChanged
Google docs link

Maybe you should do this setListAdapter(listAdapter);

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top