Compartilhar via


View.OnDragEvent(DragEvent) Method

Definition

Handles drag events sent by the system following a call to android.view.View#startDragAndDrop(ClipData,DragShadowBuilder,Object,int) startDragAndDrop().

[Android.Runtime.Register("onDragEvent", "(Landroid/view/DragEvent;)Z", "GetOnDragEvent_Landroid_view_DragEvent_Handler")]
public virtual bool OnDragEvent (Android.Views.DragEvent? e);
[<Android.Runtime.Register("onDragEvent", "(Landroid/view/DragEvent;)Z", "GetOnDragEvent_Landroid_view_DragEvent_Handler")>]
abstract member OnDragEvent : Android.Views.DragEvent -> bool
override this.OnDragEvent : Android.Views.DragEvent -> bool

Parameters

e
DragEvent

The DragEvent sent by the system. The Action method returns an action type constant defined in DragEvent, indicating the type of drag event represented by this object.

Returns

true if the method successfully handled the drag event, otherwise false. <p> The method must return true in response to an DragEvent#ACTION_DRAG_STARTED ACTION_DRAG_STARTED action type to continue to receive drag events for the current drag and drop operation. <p> The method should return true in response to an DragEvent#ACTION_DROP ACTION_DROP action type if the dropped data was consumed (at least partially); false, if none of the data was consumed. <p> For all other events, the return value is false.

Attributes

Remarks

Handles drag events sent by the system following a call to android.view.View#startDragAndDrop(ClipData,DragShadowBuilder,Object,int) startDragAndDrop().

The system calls this method and passes a DragEvent object in response to drag and drop events. This method can then call DragEvent#getAction() to determine the state of the drag and drop operation.

The default implementation returns false unless an OnReceiveContentListener has been set for this view (see #setOnReceiveContentListener), in which case the default implementation does the following: <ul> <li>Returns true for an DragEvent#ACTION_DRAG_STARTED ACTION_DRAG_STARTED event <li>Calls #performReceiveContent for an DragEvent#ACTION_DROP ACTION_DROP event <li>Returns true for an DragEvent#ACTION_DROP ACTION_DROP event if the OnReceiveContentListener consumed some or all of the content </ul>

Java documentation for android.view.View.onDragEvent(android.view.DragEvent).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to