Create an adapter class for your listView.
class MyAdapter extends BaseAdapter {
ArrayList<Item> items;
// Override all other needed methods.
//Add method to add items to list from outside.
public void addItems(Item item) {
items.add(item);
adapter.notifyDataSetChanged();
}
}
Inside your activity
// Crate MyAdapter instance an assign to listview like-
listView,setAdapter(adapter);
Item item= new Item();
//Add necessary properties in item. and add item to list.
adapter.addItem(item);
This is the overall idea . Look around this. Should work.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…