I assume that you have a desktop, for example an application, at least a view with the elements you want to drag.
As Austin Mahoney says in his comment, you can link to the Android home desktop with a strong one. But since drag and drop is an easy-to-use feature, you can handle it too.
You need your items for storage, for example. an array . Then view the types of events.
On each ACTION_DOWN you need to check if the user has been hit. For example. if we have circles as elements, we need to fix the current ACTION_DOWN coordinates so that we can check that they are inside the element and get the identifier of the element that the user is going to drag, in accordance with the ACTION_DOWN coordinates.
In ACTION_MOVE, you just need to pass the current x and y coordinates to the element in order to redraw it at the new position.
Well, it's just a drag and drop function. Now you need to check that the element is in a specific sector that you are calling bin. This way you define a rectangle on the screen. in ACTION_MOVE your test so that the element is in this area is all.
Just a sample drag and drop code:
public boolean onTouchEvent(MotionEvent event){ int itemID = 0; int X = (int)event.getX(); int Y = (int)event.getY(); switch(event.getAction()){ case MotionEvent.ACTION_DOWN: for(Items item : dragable_item){
If you want to dig more into the code, see anddev.org - drag and drop.
Lost in owl
source share