File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to Refresh ListView in Android

 
Sreenu Vengala
Greenhorn
Posts: 18
  • 0
  • 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
 
Monu Tripathi
Rancher
Posts: 1369
1
Android Eclipse IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
invalidate() doesn't work?
 
Kopparthi Ayyanababu
Greenhorn
Posts: 2
  • 0
  • 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
 
Piyush Patel
Ranch Hand
Posts: 127
Android Firefox Browser Ubuntu
  • 0
  • 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 !

 
Natali Lapshina
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you use SimpleCursorAdapter? then try
Cursor cursor = new .....;
cursor.requery();
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • 0
  • 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
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic