I want to create swipe listview, when user swipe right to left on an listview item, user will be show some button options.
It look like below image :
I have been seen some swipe listview library, but it isn't what I need.
Can anyone help me suggest to me the library that can do build my listview?
Thanks.
I used to have the same problem as your, I couldn't find a library to swipe to show other buttons so I ended up writing a new library for myself. Check out my library: SwipeRevealLayout
For your specific layout, the usage is the following:
Add dependencies:
compile 'com.chauthai.swipereveallayout:swipe-reveal-layout:1.0.0'
In your row.xml file:
<com.chauthai.swipereveallayout.SwipeRevealLayout
android:layout_width="match_parent"
android:layout_height="70dp"
app:mode="normal"
app:dragEdge="right">
<!-- Your delete and edit buttons layout here -->
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="horizontal">
<!-- put your buttons here -->
</LinearLayout>
<!-- Your main layout here -->
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent" />
</com.chauthai.swipereveallayout.SwipeRevealLayout>
And finally in your adapter (RecyclerView or ListView) class, when you bind your view, use ViewBinderHelper:
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
}
}