Ontouch() Action_move Case Is Not Called While Dragging
Solution 1:
Indeed, the startDrag(...)
prevents your View from receiving further touch events. It seems like as soon as the drag and drop starts, an overlay is created, covering the whole screen and consuming all the touch events. Only the drag events will be sent to ALL views on your screen.
This can be found in startDrag
's documentation :
Once the system has the drag shadow, it begins the drag and drop operation by sending drag events to all the View objects in your application that are currently visible. It does this either by calling the View object's drag listener (an implementation of onDrag() or by calling the View object's onDragEvent() method. Both are passed a DragEvent object that has a getAction() value of ACTION_DRAG_STARTED
How to handle the drag events can be found in this part of the documentation:
Drag and Drop - Handling events during the drag
Try to extend your existing code to catch the drag events:
// inside onCreate(), needs "implements View.OnDragListener"
card.setOnDragListener(this);
public boolean onDrag(View v, DragEvent event) {
// Defines a variable to store the action type for the incoming event
final int action = event.getAction();
// Handles each of the expected eventsswitch(action) {
case DragEvent.ACTION_DRAG_LOCATION:
final int x = event.getX();
final int y = event.getY();
Log.d("prefs", "X=" + String.valueOf(x) + " / Y=" + String.valueOf(y));
break;
}
returntrue;
}
Post a Comment for "Ontouch() Action_move Case Is Not Called While Dragging"