Chapter 22. Drag-and-drop
This chapter covers
- The drag-and-drop classes
- Drag-and-drop operations
- The shadow builder
- Listening for drag-and-drop events
Starting with Android 3.0 (API 11), developers can add drag-and-drop capabilities to applications. Drag-and-drop support is one of the neat features added in Android 3.0, a natural addition to touch-based user interfaces and tablets. Android 3.0 provides a complete framework for drag-and-drop that consists of multiple classes, events, and operations. Related to drag-and-drop are copy-and-paste operations. Although copy and paste has been around since API 1, a much richer clipboard API has been introduced in API 11.
Drag-and-drop is a touch-based gesture. With drag-and-drop gestures, you can allow users to move data across views that reside within in the same layout: for example, to select data items in one view and drop them onto a different view for the purpose of sharing or synchronizing data items. Or you can use the drag-and-drop gesture itself to trigger a specific action against the dragged item: for example, viewing the selected item’s details. A typical drag-and-drop operation is shown in figure 22.1.