File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Android and the fly likes How to Refresh ListView in Android Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » Android
Bookmark "How to Refresh ListView in Android" Watch "How to Refresh ListView in Android" New topic
Author

How to Refresh ListView in Android

Sreenu Vengala
Greenhorn

Joined: Oct 26, 2009
Posts: 18
Can anyone help on how to refresh ListView when I add some dynamic data in Android.

Thanks
Srini
Monu Tripathi
Rancher

Joined: Oct 12, 2008
Posts: 1369

invalidate() doesn't work?


[List of FAQs] | [Android FAQ] | [Samuh Varta]
Kopparthi Ayyanababu
Greenhorn

Joined: Jul 03, 2009
Posts: 2
Hi Sreenu can you help me how to add items dynamically to listview from previous window to listview window by clicking Add button
Piyush Patel
Ranch Hand

Joined: Feb 24, 2009
Posts: 127

To refresh data in list view ,
following is the code you written for List view Data ,
setListAdapter(yourAdapter);
here, in example yourAdapter can be ArrayList or any of List of Adapters .
now , when you want to refresh data in list call ,
yourAdapter.notifyDataSetChanged(); and you are done !


[My Blog] [ Follow @Twitter] | Innovations never goes out of Style...
Natali Lapshina
Greenhorn

Joined: Jan 24, 2011
Posts: 1
If you use SimpleCursorAdapter? then try
Cursor cursor = new .....;
cursor.requery();
Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6657
    
    5

Natali Lapshina wrote:If you use SimpleCursorAdapter? then try
Cursor cursor = new .....;
cursor.requery();


Requery is now deprecated and should not be used. You can instead use a Loader and an observer inside this loader to tell the list view that the content has changed and must be reloaded. Take a look at this tutorial to get yourself started

http://www.androiddesignpatterns.com/2012/07/loaders-and-loadermanager-background.html


SCJP 6 articles - SCJP 5/6 mock exams - More SCJP Mocks
 
jQuery in Action, 2nd edition
 
subject: How to Refresh ListView in Android
 
Similar Threads
Multicolumn checked ListView
Problem with Customised ListView
Google Admob Integration Errors
How to conditionally change text color?
how to remove ListView Activity Lines in Android