Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

update listview dynamically with adapter

This tutorial uses a SimpleAdapter which works fine, but I need to update the arrays in the adapter when new data is entered.

Could you please guide me on how to update a ListView using something other than a SimpleAdapter?

like image 362
dell116 Avatar asked Mar 16 '11 02:03

dell116


People also ask

How can you update a ListView dynamically?

This example demonstrates how do I dynamically update a ListView in android. Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main. xml.

How do I refresh a ListView adapter?

To refresh the ListView in Android, call notifyDataSetChanged() method on the Adapter that has been set with the ListView. Also note that the method notifyDataSetChanged() has to be called on UI thread.


1 Answers

Use a ArrayAdapter backed by an ArrayList. To change the data, just update the data in the list and call adapter.notifyDataSetChanged().

like image 152
Robby Pond Avatar answered Sep 21 '22 06:09

Robby Pond