diff --git a/core/java/android/view/DragEvent.java b/core/java/android/view/DragEvent.java index 2baa0b4691ab6..16f2d7d0b6c7e 100644 --- a/core/java/android/view/DragEvent.java +++ b/core/java/android/view/DragEvent.java @@ -26,7 +26,7 @@ import com.android.internal.view.IDragAndDropPermissions; //TODO: Improve Javadoc /** * Represents an event that is sent out by the system at various times during a drag and drop - * operation. It is a complex data structure that contains several important pieces of data about + * operation. It is a data structure that contains several important pieces of data about * the operation and the underlying data. *
* View objects that receive a DragEvent call {@link #getAction()}, which returns @@ -161,8 +161,8 @@ public class DragEvent implements Parcelable { * event when they are added or becoming visible. *
*- * A View only receives further drag events if it returns {@code true} in response to - * ACTION_DRAG_STARTED. + * A View only receives further drag events for the drag operation if it returns {@code true} + * in response to ACTION_DRAG_STARTED. *
* @see #ACTION_DRAG_ENDED * @see #getX() @@ -172,8 +172,9 @@ public class DragEvent implements Parcelable { /** * Action constant returned by {@link #getAction()}: Sent to a View after - * {@link #ACTION_DRAG_ENTERED} if the drag shadow is still within the View object's bounding - * box. The {@link #getX()} and {@link #getY()} methods supply + * {@link #ACTION_DRAG_ENTERED} while the drag shadow is still within the View object's bounding + * box, but not within a descendant view that can accept the data. The {@link #getX()} and + * {@link #getY()} methods supply * the X and Y position of of the drag point within the View object's bounding box. ** A View receives an {@link #ACTION_DRAG_ENTERED} event before receiving any @@ -355,9 +356,10 @@ public class DragEvent implements Parcelable { /** * Returns the {@link android.content.ClipData} object sent to the system as part of the call * to - * {@link android.view.View#startDrag(ClipData,View.DragShadowBuilder,Object,int) startDrag()}. + * {@link android.view.View#startDragAndDrop(ClipData,View.DragShadowBuilder,Object,int) + * startDragAndDrop()}. * This method only returns valid data if the event action is {@link #ACTION_DROP}. - * @return The ClipData sent to the system by startDrag(). + * @return The ClipData sent to the system by startDragAndDrop(). */ public ClipData getClipData() { return mClipData; @@ -366,12 +368,14 @@ public class DragEvent implements Parcelable { /** * Returns the {@link android.content.ClipDescription} object contained in the * {@link android.content.ClipData} object sent to the system as part of the call to - * {@link android.view.View#startDrag(ClipData,View.DragShadowBuilder,Object,int) startDrag()}. + * {@link android.view.View#startDragAndDrop(ClipData,View.DragShadowBuilder,Object,int) + * startDragAndDrop()}. * The drag handler or listener for a View can use the metadata in this object to decide if the * View can accept the dragged View object's data. *
* This method returns valid data for all event actions except for {@link #ACTION_DRAG_ENDED}. - * @return The ClipDescription that was part of the ClipData sent to the system by startDrag(). + * @return The ClipDescription that was part of the ClipData sent to the system by + * startDragAndDrop(). */ public ClipDescription getClipDescription() { return mClipDescription; @@ -384,7 +388,8 @@ public class DragEvent implements Parcelable { /** * Returns the local state object sent to the system as part of the call to - * {@link android.view.View#startDrag(ClipData,View.DragShadowBuilder,Object,int) startDrag()}. + * {@link android.view.View#startDragAndDrop(ClipData,View.DragShadowBuilder,Object,int) + * startDragAndDrop()}. * The object is intended to provide local information about the drag and drop operation. For * example, it can indicate whether the drag and drop operation is a copy or a move. *
@@ -394,7 +399,7 @@ public class DragEvent implements Parcelable { *
* This method returns valid data for all event actions except for {@link #ACTION_DRAG_ENDED}. *
- * @return The local state object sent to the system by startDrag(). + * @return The local state object sent to the system by startDragAndDrop(). */ public Object getLocalState() { return mLocalState; diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index d060aac4251de..6e18d6c5a5ba1 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -20830,6 +20830,9 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * {@link android.view.DragEvent#ACTION_DROP} if it consumed the drop, or * {@code false} if it didn't. * + *+ * For all other events, the return value is ignored. + *
*/ public boolean onDragEvent(DragEvent event) { return false; diff --git a/docs/html/guide/topics/ui/drag-drop.jd b/docs/html/guide/topics/ui/drag-drop.jd index 4a87cd4938cbc..bae3fe663800e 100644 --- a/docs/html/guide/topics/ui/drag-drop.jd +++ b/docs/html/guide/topics/ui/drag-drop.jd @@ -157,19 +157,22 @@ DraggableDot.java inThe system first responds by calling back to your application to get a drag shadow. It then displays the drag shadow on the device. @@ -199,12 +204,13 @@ DraggableDot.java
@@ -297,7 +304,8 @@ DraggableDot.java
in table 2. It is also described in detail with the event for which it is valid in the section @@ -316,8 +324,9 @@ DraggableDot.java in {@link android.view.DragEvent#ACTION_DRAG_EXITED}@@ -751,7 +762,9 @@ imageView.setOnLongClickListener(new View.OnLongClickListener() { {@link android.view.DragEvent#ACTION_DRAG_LOCATION}: Once the listener receives an {@link android.view.DragEvent#ACTION_DRAG_ENTERED} event, and before it receives an A{@link android.view.DragEvent#ACTION_DRAG_EXITED} event, it receives a new - {@link android.view.DragEvent#ACTION_DRAG_LOCATION} event every time the touch point moves. + {@link android.view.DragEvent#ACTION_DRAG_LOCATION} event immediately after the + {@link android.view.DragEvent#ACTION_DRAG_ENTERED} event, and then every time the touch + point moves. The {@link android.view.DragEvent#getX()} and {@link android.view.DragEvent#getY()} methods return the X and Y coordinates of the touch point. @@ -769,9 +782,9 @@ imageView.setOnLongClickListener(new View.OnLongClickListener() {
- When the user releases the drag shadow on a View in the application, and that View previously + When the user releases the drag shadow on a View in the application, but not on its descendant + view that can accept the data, and that View previously reported that it could accept the content being dragged, the system dispatches a drag event to that View with the action type {@link android.view.DragEvent#ACTION_DROP}. The listener should do the following: @@ -800,8 +813,8 @@ imageView.setOnLongClickListener(new View.OnLongClickListener() {
true to the system.
-