Tag Archives: drag-drop

Drag-Drop for Android GridView (V4)

About a year and a half ago, I built an example Android app that allows you to drag images from one spot on a GridView to another. I have had several requests to show how the drag-drop framework used in that example could be adapted to the current Android support (V4+) for drag-drop operations. I have done that work and I am making the source code available in this post.

The sample app works the same as the one described in “Drag-Drop for An Android GridView”. There is a grid displayed on the screen. An “Add Image” button allows you to add images to the screen. Those images can be dragged onto the grid. Any images in the grid can be dragged around from one spot to another. There is also a trash can icon on the screen. Images can be dragged there to remove them from the screen. Continue reading

Posted in Android | Tagged , , , | 42 Comments

Improved Drag-Drop for an Android GridView

I have an improved version of my tutorial app described in “Drag-Drop for an Android GridView”. It allows a drag-drop sequence to be initiated from any touch event. The earlier version required the user to do a long click (press) before dragging would start.
Continue reading

Posted in Android | Tagged , , , | 114 Comments

Drag-Drop for an Android GridView

It’s time for another tutorial on drag-drop in Android. I have written several other articles on this topic (Part 1, Part 2, Part 3), but the last one was back in February. I have learned quite a bit since then.

This time I built a demo that allows you to add images dynamically to the screen and then drag them onto a GridView. You can then move the images around in the GridView or move them to the trash.

Full source code for the demo app is provided. Continue reading

Posted in Android | Tagged , , | 324 Comments

Moving Views In Android – Part 3, Drop Zones

Part 3 of my “Moving Views in Android” notes covers the drop side of drag-drop. It shows you how you can different behaviors associated with different areas of the screen. Continue reading

Posted in Android | Tagged , , , | 107 Comments

Moving Views In Android – Part 2, Drag and Drop

This is part 2 of my investigation into how to get views on an Android screen that a user can move by touching them and dragging them. For Moving Views in Android – Part 1, I had a couple of images positioned on the screen and got the images to move on the screen. It turns out that the views themselves were not moving, just the images within the bounds of the view. In the work that I describe here, I actually have the views moving. The key was to have a custom ViewGroup to coordinate drag and drop events for all views within the layout. Continue reading

Posted in Android | Tagged , , , , | 171 Comments