Add/Remove Items to Android ListView
I am creating a listv开发者_开发技巧iew 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
from your item array just remove or add item and call your adapter's notifyDataSetChanged()
remove/add an element and use this.
((BaseAdapter) listView.getAdapter()).notifyDataSetInvalidated();
精彩评论