-1

how to refresh List View dynamic data content in android? I tried loading dynamic data for the List View in android application but no luck .Any advice how to accomplish this?

si esw
  • 3
  • 1

1 Answers1

0

Call notifyDataSetChanged() on your Adapter object once you've modified the data in that adapter. Some additional specifics on how/when to call notifyDataSetChanged() can be viewed in this Google I/O video.

Or else Look at this link.it may helpful. Dynamic ListView in Android app Or else The right thing to do is to call notifyDataSetChanged() on your Adapter. Troubleshooting If calling notifyDataSetChanged() doesn't work all the layout methods won't help either. Believe me the list view was properly updated. If you fail to find the difference you need to check where the data in your adapter comes from. If this is just a collection you're keeping in memory check that you actually deleted the item from the collection before calling the notifyDataSetChanged(). If you're working with a database or service backend you'll have to call the method to retrieve the information again (or manipulate the in memory data) before calling the notifyDataSetChanged(). The thing is this notifyDataSetChanged only works if the dataset has changed. So that is the place to look if you don't find changes coming through. Debug if needed. UI Thread It is true that this has to be called from the UI thread. Other answers have examples on how to achieve this. However this is only required if you're working on this information from outside the UI thread. That is from a service or a non UI thread. In simple cases you'll be updating your data from a button click or another activity/fragment. So still within the UI thread. No need to always pop that runOnUiTrhead in. More Information Another nice post about the power of list Views is found here:http://www.vogella.com/articles/AndroidListView/article.html

Community
  • 1
  • 1
Siva
  • 26
  • 2