EditMode
List of edit mode, including delete, sort function.
Usage
Add the dependencies to your gradle file:
dependencies {
compile 'com.southernbox:EditMode:1.0.0'
}
In the activity layout file, replace the RecyclerView with EditRecyclerView:
<com.southernbox.editmode.EditRecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
Use EditLayout in the item layout file:
<com.southernbox.editmode.EditLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/edit_layout"
android:layout_width="match_parent"
android:layout_height="@dimen/item_height">
<!--Delete Button-->
<!--Content-->
<!--PreDelete button-->
<!--Content-->
<!--Sort Button--> </com.southernbox.editmode.EditLayout>
Extend EditAdapter:
public class MyAdapter extends EditAdapter<Entity> {
MyAdapter(Context context, List<Entity> list) {
super(context, list);
}
@Override
public EditViewHolder onCreateEditViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(mContext).inflate(R.layout.item_list, parent, false);
return new ViewHolder(view);
}
@Override
public void onBindEditViewHolder(EditViewHolder holder, int position) {
// bind holder.vContent
}
private static class ViewHolder extends EditViewHolder {
// ...
}
}