I need to implement swipe to delete in a ListView
with Undo function as in Gmail App
I know that there are questions already asking about swipe to delete like
Remove item listview with Slide - Like Gmail
and
android swipe to delete list row
But none of them explains how to manage Undo after deletion and Animate back the deleted view on undo!
I found other one with no Answer here
How to implement gmail like Achieve or Undo action in a list item
So here is my question.
How to create a listview in android with swipe to delete then show UNDO in the deleted space and Animate back the same view if the undo is pressed, also remove the undo option on scroll or other item click or swipe?
You smart people have any idea?
| ----------- ITEM 1-----------|
| ----------- ITEM 2-----------|
| --Deleted-------<[UNDO]>|
| ----------- ITEM 4-----------|
| ----------- ITEM 5-----------|
note: sorry that I cant add an image because of my low reputation!
Android Swipe To Delete. Swipe to delete feature is commonly used to delete rows from a RecyclerView. In order to implement Swipe to delete feature, we need to use the ItemTouchHelper utility class.
You can find exactly what you asked for at https://github.com/nhaarman/ListViewAnimations
Your question sounds like you're confused about how to manage the actual undo part. If that is the case then I would suggest you look into the design pattern called 'Command Design Pattern'. You can queue up 'Commands' like delete, then only commit them once the undo timer or however you implement it is finished.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With