Sunday, 4 December 2016

Implementing Swipe For Delete Item And Undo On RecyclerView Android

After previous post, i was posted swipe for delete, edit and share item on Recyclerview. But on that post there's no Undo function to cancel delete item.

For more detail article please kindly read : Swipe for delete, edit and share item on Recyclerview


In this tutorial, i still use THIS PROJECT, so i just post the code that related with swipe function.

There is no much steps you will do, just write a several line codes in your MainActivity.java or wherever you define your Recyclerview. In this case, I define the Recyler view in MainActivity.java

For Undo function, we will use on the the newest materials called Snackbar. Snackbar will appears at the bottom when you delete the item.

For use Snackbar, make sure you have compiled this library in your build.gradle(Module:app) :

compile 'com.android.support:design:25.0.1

After that, in you class where you define the recyclerview, paste the code below :

That's all, enjoy it!!

This Is The Oldest Page


EmoticonEmoticon