added in version 24.1.0
belongs to Maven artifact


public static abstract class ItemTouchHelper.SimpleCallback
extends ItemTouchHelper.Callback


A simple wrapper to the default Callback which you can construct with drag and swipe directions and this class will handle the flag callbacks. You should still override onMove or onSwiped depending on your use case.

 ItemTouchHelper mIth = new ItemTouchHelper(
     new ItemTouchHelper.SimpleCallback(ItemTouchHelper.UP | ItemTouchHelper.DOWN,
         ItemTouchHelper.LEFT) {
         public abstract boolean onMove(RecyclerView recyclerView,
             ViewHolder viewHolder, ViewHolder target) {
             final int fromPos = viewHolder.getAdapterPosition();
             final int toPos = target.getAdapterPosition();
             // move item in `fromPos` to `toPos` in adapter.
             return true;// true if moved, false otherwise
         public void onSwiped(ViewHolder viewHolder, int direction) {
             // remove from adapter


Inherited constants

From class

Public constructors

ItemTouchHelper.SimpleCallback(int dragDirs, int swipeDirs)

Creates a Callback for the given drag and swipe allowance.

Public methods

int getDragDirs(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder)

Returns the drag directions for the provided ViewHolder.

int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder)

Should return a composite flag which defines the enabled move directions in each state (idle, swiping, dragging).

int getSwipeDirs(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder)

Returns the swipe directions for the provided ViewHolder.

void setDefaultDragDirs(int defaultDragDirs)

Updates the default drag directions.

void setDefaultSwipeDirs(int defaultSwipeDirs)

Updates the default swipe directions.

Inherited methods

From class