• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to Refresh ListView in Android  RSS feed

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anyone help on how to refresh ListView when I add some dynamic data in Android.

Thanks
Srini
 
Rancher
Posts: 1369
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
invalidate() doesn't work?
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sreenu can you help me how to add items dynamically to listview from previous window to listview window by clicking Add button
 
Ranch Hand
Posts: 127
Android Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 !

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you use SimpleCursorAdapter? then try
Cursor cursor = new .....;
cursor.requery();
 
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!