Drag-and-Drop Example Application

For your next example application, you’re going to employ a staple of 3.0, the fragments. This, among other things, will prove that drags can cross fragment boundaries. You’ll create a palette of dots on the left and a square target on the right. When a dot is grabbed using a long click, you’ll change the color of that dot in the palette and Android will show a shadow of the dot as you drag. When the dragged dot reaches the square target, the target will begin to glow. If you drop the dot on the square target, a message will indicate that you’ve just added one more drop to the drop count, the glowing will stop, and the original dot will go back to its original color.

List of Files

This application builds upon ...

Get Pro Android 4 now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.