Reputation: 170
private String[] listView2 = {"aa","bb","cc","dd","ee"};
listView1 = (ListView)findViewById(R.id.listView1);
listAdapter = new ArrayAdapter(this,android.R.layout.simple_list_item_1,listView2);
listView1.setAdapter(listAdapter);
Change listView2[1] to "zzz".
Following code isn't work.
listView2[1] = "zzz";
Upvotes: 2
Views: 184
Reputation: 170
Try this.^_^
public void newListView(){
listAdapter = new ArrayAdapter(this,android.R.layout.simple_list_item_1,listView2);
listView1.setAdapter(listAdapter);
}
listView2[0] = "zz";
newListView();
Upvotes: 0
Reputation: 6515
you can update adapter like this:
adapter.insert("zz", 1);
adapter.notifyDataSetChanged();
Upvotes: 0
Reputation: 11909
you also need to call
listAdapter.notifyDataSetChanged();
Or use one of the listAdpater methods for changing the data:
add(T), insert(T, int), remove(T), clear()
Upvotes: 1