Reputation: 64844
I want to know how to add a new text view to appearing ListView
in android, ( for example. when I click on some button a new list item is added to the list view )?
Upvotes: 0
Views: 3884
Reputation: 20319
You simply add the object to the container that contains the objects displayed by the listview. Then you tell the listView adapter that a change has occured:
public void onClick(View v) {
list.add(someObject);
((ArrayAdapter<Object>) listView.getAdapter()).notifyDataSetChanged();
Upvotes: 3
Reputation: 11
notifyDataSetChanged is enough. I have used it. When I used setContentView(R.layout.list_view);
my screen turned white. On removing setContentView(R.layout.list_view); it worked like a charm!!!
Upvotes: 0