Google is committed to advancing racial equity for Black communities. See how.


abstract class SimpleCallback : ItemTouchHelper.Callback
   ↳ androidx.recyclerview.widget.ItemTouchHelper.Callback
   ↳ androidx.recyclerview.widget.ItemTouchHelper.SimpleCallback

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 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
Public constructors
<init>(dragDirs: Int, swipeDirs: Int)

Creates a Callback for the given drag and swipe allowance.

Public methods
open Int
getDragDirs(@NonNull recyclerView: RecyclerView, @NonNull viewHolder: RecyclerView.ViewHolder)

Returns the drag directions for the provided ViewHolder.

open Int
getMovementFlags(@NonNull recyclerView: RecyclerView, @NonNull viewHolder: RecyclerView.ViewHolder)

open Int
getSwipeDirs(@NonNull recyclerView: RecyclerView, @NonNull viewHolder: RecyclerView.ViewHolder)

Returns the swipe directions for the provided ViewHolder.

open Unit
setDefaultDragDirs(defaultDragDirs: Int)

Updates the default drag directions.

open Unit
setDefaultSwipeDirs(defaultSwipeDirs: Int)

Updates the default swipe directions.

Inherited functions