I have an ArrayAdapter holding a list of updating elements (e.g., a list of async-loaded news items).
What is the proper pattern so that, when an element's value changes, it updates the View?
I have an ArrayAdapter holding a list of updating elements (e.g., a list of async-loaded news items).
What is the proper pattern so that, when an element's value changes, it updates the View?
Use notifyDataSetChanged to reflect updates in your listView
adapter.notifyDataSetChanged();
You can use methods like ArrayAdapter#add()
, ArrayAdapter#addAll()
, etc. These will update the View that is bound to the adapter automatically.
Or you can use the same methods on the List that the adapter reads and call ArrayAdapter#notifyDataSetChanged()
yourself.