Android 12 Developer Preview is here! Try it out, and give us your feedback!


interface OnDragInitiatedListener

Register an OnDragInitiatedListener to be notified when user intent to perform drag and drop operations on an item or items has been detected. Handle these events using View support for Drag and drop.

See View#startDragAndDrop(ClipData, View.DragShadowBuilder, Object, int) for details.


Public methods
abstract Boolean

Called when user intent to perform a drag and drop operation has been detected.

Public methods


abstract fun onDragInitiated(@NonNull e: MotionEvent): Boolean

Called when user intent to perform a drag and drop operation has been detected.

The following circumstances are considered to be expressing drag and drop intent:

  1. Long press on selected item.
  2. Click and drag in the drag region of selected item with a pointer device.
  3. Click and drag in drag region of un-selected item with a pointer device.

The RecyclerView item at the coordinates of the MotionEvent is not supplied as a parameter to this method as there may be multiple items selected or no items selected (as may be the case in pointer drive drag and drop.)

Obtain the current list of selected items from SelectionTracker#copySelection(MutableSelection). If there is no selection get the item under the event using ItemDetailsLookup#getItemDetails(MotionEvent).

Drag region used with pointer devices is specified by ItemDetails#inDragRegion(MotionEvent)

See android.view.View#startDragAndDrop(ClipData, View.DragShadowBuilder, Object, int) for details on drag and drop implementation.

e MotionEvent: the event associated with the drag.
Boolean true if drag and drop was initiated.