Signed only in order to answer this because of the disappointment that you found the same, unfortunately, incorrectly, answering all over the Internet.
To process an object that looms outside the view, configure OnDragListener for the object, then call the handler from there - it will work if you do not use the handler, and pass the view identifier to the handler. In addition, I found that your user can also drop the job by pressing two buttons at the same time, and when you switch actions, if the user touches the screen, you can also lose objects in the same way, so the best job was in that my handler is called from the ACTION_DRAG_ENDED drag and drop listener, and the ACTION_UP touch listener just ensures that all that should be visible is that. Thus, every time the user stops touching the screen, he corrects everything that he does.
private final class MyTouchListener implements OnTouchListener { @Override public boolean onTouch(View view, MotionEvent motionEvent) { switch (motionEvent.getAction()) { case MotionEvent.ACTION_DOWN: ClipData data = ClipData.newPlainText("", ""); DragShadowBuilder shadowBuilder = new DragShadowBuilder(view); view.startDrag(data, shadowBuilder, view, 0); view.setVisibility(View.INVISIBLE); return true; case MotionEvent.ACTION_UP: drophandler.sendEmptyMessage(0); case MotionEvent.ACTION_MOVE: return true; default: break; } return true; } } class MyDragListener implements OnDragListener { @Override public boolean onDrag(View v, DragEvent event) { View view = (View) event.getLocalState(); Button drag = (Button) view; int action = event.getAction(); switch (event.getAction()) { case DragEvent.ACTION_DRAG_STARTED: break; case DragEvent.ACTION_DRAG_ENTERED: break; case DragEvent.ACTION_DRAG_EXITED: break; case DragEvent.ACTION_DROP: Button target = (Button) v;
houndx Feb 03 '15 at 19:45 2015-02-03 19:45
source share