How to do swipe gesture on RecyclerView item without 3rd party lib

T_C picture T_C · Jan 22, 2015 · Viewed 9k times · Source

Is their any direct support for slide to delete/archive (right to left or left to right) on RecyclerView item.

And instead of delete/archive I want four buttons under the list item.

something like this https://github.com/47deg/android-swipelistview but for recyclerview and official support not any 3rd party lib

Answer

Nemanja Kovacevic picture Nemanja Kovacevic · Jan 9, 2016

Yes there is, you can do it with ItemTouchHelper class provided by the support library.

P.S. I had to do this the other day and also wanted to avoid using 3rd party lib if possible. The library might be doing much more than you need and because of that it might be more complex than necessary in your case. It can also unnecessary grow your method count. This is just a sample of reasons why you should avoid adding lib as a quick fix for your problem.

EDIT: I had a go at this, see this blog post and this github repo.