开发者

Add/Remove Items to Android ListView

开发者 https://www.devze.com 2023-04-12 12:05 出处:网络
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.setA

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();
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号