How do I delete an item from my custom base adapter?

后端 未结 5 1694
半阙折子戏
半阙折子戏 2020-12-16 22:29

I am extending BaseAdapter to make a custom listview row. I have context menu that opens everytime a user holds on the row and prompts if he wants to delete it. However how

5条回答
  •  情书的邮戳
    2020-12-16 23:02

    You do not delete from the adapter ! You delete from the items ! and the adapter is between your items and the view. From the view you can get the position and according the position you can delete items. Then the adapter will refresh you views.

    That means you need to do something like this

     items.remove(position);
    adapter.notifyDataSetChanged()
    

提交回复
热议问题