Android Drag and Drop Tutorial: Moving Views and Data | Kodeco

This content was released on Aug 30 2021. The official support period is 6-months from this date.

Learn how to use Android’s drag-and-drop framework to enable an advanced gesture-based user experience.


This is a companion discussion topic for the original entry at https://www.kodeco.com/24508555-android-drag-and-drop-tutorial-moving-views-and-data
1 Like

Thanks very much for this, you have helped immensely in identifying key components like Clipdata to keep a reference of the image being dragged. I had a lot of trouble with drag and drop operations and could not understand how to keep track of the image being dragged. For example, in “setOnLongClickListener” lambda, I did not understand how to return “it” (or the View! innerscope value) outside the wrapped function. I tried setting an outerscope variable, and then assigning “it” to the variable, but it would of course remain the same.

That was one aspect I was having difficulty with, and the tutorial helped a lot. It also helped me understand DragEvents, and how to implement the whole shabang properly. I hope you can post more tutorials for us noobs!