Drag and Drop to Level 10 API in Android

I need to create an application in which I can drag one view to another, retrieving the data of the draggable view. (Similar to how one drags and places an icon in the trash).

I found this guide , but unfortunately it requires an API level of level 11, and my application must be for API level 10 (ginger).

How do I do what I need?

Thanks in advance.

+4
source share
1 answer

You can use OnClickEvent or onTouchEvent to do this & lt; 10 API

I use the following code to represent:

public boolean onTouch(View view, MotionEvent event) { view.bringToFront(); switch (event.getAction() & MotionEvent.ACTION_MASK) { case MotionEvent.ACTION_DOWN: Log.i(TAG,"Action Down"); break; case MotionEvent.ACTION_MOVE: Log.i(TAG,"Action Move"); break; case MotionEvent.ACTION_UP: Log.i(TAG,"Action Up"); break; } return true; } 

Follow also this example (there is also a basket) :) I hope this helps you.

0
source

All Articles