Reputation: 1
I can't seem to figure out how ListView works. I need to add an item to the ListView at runtime, just like this picture:
I'm not able to use a database, so the data must be in the adapter or in an ArrayList
.
Upvotes: 0
Views: 572
Reputation: 2737
If you need to add a new item to a ListView
after you have passed in your ListAdapter
, simply add the new data to the underlying collection, and call notifyDataSetChanged()
on your ListAdapter
(Assuming you are using an adapter implementation derived from BaseAdapter
).
Upvotes: 3