Stay organized with collections
Save and categorize content based on your preferences.
View.OnDragListener
public
static
interface
View.OnDragListener
android.view.View.OnDragListener
|
Interface definition for a listener that's invoked when a drag event is dispatched to this
view. The listener is invoked before the view's own
View.onDragEvent(android.view.DragEvent)
method. To fall back to the view's
onDragEvent(DragEvent)
behavior, return false
from the listener method.
Developer Guides
For a guide to implementing drag and drop features, see the
Drag and drop developer guide.
Summary
Public methods |
abstract
boolean
|
onDrag(View v, DragEvent event)
Called when a drag event is dispatched to a view.
|
Public methods
onDrag
public abstract boolean onDrag (View v,
DragEvent event)
Called when a drag event is dispatched to a view. Enables listeners to override the
base behavior provided by View.onDragEvent(android.view.DragEvent)
.
Parameters |
v |
View : The View that received the drag event. |
event |
DragEvent : The event object for the drag event. |
Returns |
boolean |
true if the drag event was handled successfully; false , if the
drag event was not handled. Note: A false return value triggers the
view's View.onDragEvent(android.view.DragEvent) handler. |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# View.OnDragListener\n\nAdded in [API level 11](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\nView.OnDragListener\n===================\n\n*** ** * ** ***\n\n[Kotlin](/reference/kotlin/android/view/View.OnDragListener \"View this page in Kotlin\") \\|Java\n\n\n`\npublic\nstatic\n\n\ninterface\nView.OnDragListener\n`\n\n\n`\n\n\n`\n\n|----------------------------------|\n| android.view.View.OnDragListener |\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\nInterface definition for a listener that's invoked when a drag event is dispatched to this\nview. The listener is invoked before the view's own\n[View.onDragEvent(android.view.DragEvent)](/reference/android/view/View#onDragEvent(android.view.DragEvent)) method. To fall back to the view's\n`onDragEvent(DragEvent)` behavior, return `false` from the listener method.\n\n### Developer Guides\n\nFor a guide to implementing drag and drop features, see the\n[Drag and drop](/guide/topics/ui/drag-drop) developer guide.\n\n\u003cbr /\u003e\n\nSummary\n-------\n\n| ### Public methods ||\n|---------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ` abstract boolean` | ` `[onDrag](/reference/android/view/View.OnDragListener#onDrag(android.view.View,%20android.view.DragEvent))`(`[View](/reference/android/view/View)` v, `[DragEvent](/reference/android/view/DragEvent)` event) ` Called when a drag event is dispatched to a view. |\n\nPublic methods\n--------------\n\n### onDrag\n\nAdded in [API level 11](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic abstract boolean onDrag (View v, \n DragEvent event)\n```\n\nCalled when a drag event is dispatched to a view. Enables listeners to override the\nbase behavior provided by [View.onDragEvent(android.view.DragEvent)](/reference/android/view/View#onDragEvent(android.view.DragEvent)).\n\n\u003cbr /\u003e\n\n| Parameters ||\n|---------|----------------------------------------------------------|\n| `v` | `View`: The `View` that received the drag event. \u003cbr /\u003e |\n| `event` | `DragEvent`: The event object for the drag event. \u003cbr /\u003e |\n\n| Returns ||\n|-----------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `boolean` | `true` if the drag event was handled successfully; `false`, if the drag event was not handled. **Note:** A `false` return value triggers the view's [View.onDragEvent(android.view.DragEvent)](/reference/android/view/View#onDragEvent(android.view.DragEvent)) handler. \u003cbr /\u003e |"]]