Swipe ListView item From right to left show delete button
EDIT:between other options there's a nice library that could solve your issue:https://github.com/daimajia/AndroidSwipeLayout
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:
<com.chauthai.swipereveallayout.SwipeRevealLayout android:layout_width="match_parent" android:layout_height="match_parent" app:mode="same_level" app:dragEdge="left"> <!-- Your secondary layout here --> <FrameLayout android:layout_width="wrap_content" android:layout_height="match_parent" /> <!-- Your main layout here --> <FrameLayout android:layout_width="match_parent" android:layout_height="match_parent" /></com.chauthai.swipereveallayout.SwipeRevealLayout>
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(); @Override 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 }}
i've searched google a lot and find the best suited project is the swipmenulistview https://github.com/baoyongzhang/SwipeMenuListView on github.