Swipe ListView item From right to left show delete button


I have a custom ListView showing the list of words selecting from database. When I swipe this listview item i want to show Delete button like image below. And when I press that button it is deleted from Database and refresh the listview. mSwipe Listview item

I already look in this sample code here. But it still does not work.

This question is tagged with android android-listview swipe-gesture

~ Asked on 2013-12-27 08:02:09

The Best Answer is


EDIT: between other options there's a nice library that could solve your issue: https://github.com/daimajia/AndroidSwipeLayout

~ Answered on 2013-12-27 08:15:21


I used to have the same problem finding a good library to do that. Eventually, I created a library which can do that: SwipeRevealLayout

In gradle file:

dependencies {
    compile 'com.chauthai.swipereveallayout:swipe-reveal-layout:1.4.0'

In your xml file:


    <!-- Your secondary layout here -->
        android:layout_height="match_parent" />

    <!-- Your main layout here -->
        android:layout_height="match_parent" />


Then in your adapter file:

public class Adapter extends RecyclerView.Adapter {
  // This object helps you save/restore the open/close state of each view
  private final ViewBinderHelper viewBinderHelper = new ViewBinderHelper();

  public void onBindViewHolder(ViewHolder holder, int position) {
    // get your data object first.
    YourDataObject dataObject = mDataSet.get(position); 

    // Save/restore the open/close state.
    // You need to provide a String id which uniquely defines the data object.
    viewBinderHelper.bind(holder.swipeRevealLayout, dataObject.getId()); 

    // do your regular binding stuff here

~ Answered on 2016-04-17 13:22:36

Most Viewed Questions: