问题
I am creating a listview as ListView listView = new ListView(context); in my activity and I code MyCustomAdapter that extends BaseAdaptor.setting this custom adapter to my listView.setAdapter(myCustomAdpObj) object that I created as above.Now at run time I want to add/remove elements from this listView.I did't find the method how I can do this?any suggestion?thanks
回答1:
remove/add an element and use this.
((BaseAdapter) listView.getAdapter()).notifyDataSetInvalidated();
回答2:
from your item array just remove or add item and call your adapter's notifyDataSetChanged()
来源:https://stackoverflow.com/questions/7712321/add-remove-items-to-android-listview