How to delete using long click or using swipe to delete

时间:2016-04-07 10:43:47

标签: android listview

I have a listview that is working fine. Now I have one option to enable and that is deleting the row. I know this is not a problem But Want to take some suggestions. and that is what is a best way of deleting the item(row). Here what I have tries I am sharing with you

  1. Used Context Menu on long click but they do not look cool and quite old.
  2. Used Swipe to Delete but there comes some problems which are not working good, I mean there are some problems in it. here is the reference of my question about that.
  3. Can any one please come up with some suggestion of deleting the row which are new and good ways to do so.

What are prerequisites :

I am using fragments with one single activity and using tool bar so I really can use delete option appearing in toolbar for only one fragment . Actually I do not know how to do it.

So please tell me what are the good and best way which are user friendly , looks good in gui and also a Beginner developer friendly

2 个答案:

答案 0 :(得分:1)

One solution is,

  • Add hidden checkbox in each listview row.

  • Add delete button on the toolbar/actionbar.

  • OnClicking delete button show checkboxes to select multiple items to delete.

  • Again clicking on delete should ask confirmation dialog and delete if user agrees.

答案 1 :(得分:0)

您可以使用Recyclerview而不是ListView。添加/删除项目时,它具有默认动画。您可以检查代码here,也可以在项目中提供交叉图标,然后单击即可删除。