How to implement drag and drop between lists in android?

I am trying to make it so that the user can drag a text view from one list and then move it to another, and it seems to me that it is very difficult. The biggest problem I've discovered so far is that onTouchEvents seems to be heard only in the view in which the ACTION_DOWN event occurred. I will click on one list and ACTION_DOWN will be heard there. Then I pull it out of the list and go through another list. But onTouchEvent is only called for the source list, no matter where I go. I thought it would be as simple as listening to the ACTION_UP event in the receive list; but it triggered the initial list, even if I am out of it.

That I'm still a little messy. When onLongTouchEvent is called, the list tells the main action to start draggableTextView drag (which has a moveTo method). As move events continue to be called in the source list, I constantly fix the position of this draggableTextView. But I canโ€™t insert it in another list because I canโ€™t understand what I allow.

+4
source share
1 answer

Yes, you are right, this is not an easy task. However, this is possible: you can check the comonsguy cwac-touchlist example.

0
source

Source: https://habr.com/ru/post/1333846/


All Articles