-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdragitem.java
More file actions
21 lines (17 loc) · 846 Bytes
/
Copy pathdragitem.java
File metadata and controls
21 lines (17 loc) · 846 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
protected class TextViewLongClickListener implements View.OnLongClickListener {
@Override
public boolean onLongClick(View v) {
TextView thisTextView = (TextView) v;
String dragContent = "Dragged Text: " + thisTextView.getText();
//Set the drag content and type
ClipData.Item item = new ClipData.Item(dragContent);
ClipData dragData = new ClipData(dragContent,
new String[] {ClipDescription.MIMETYPE_TEXT_PLAIN}, item);
//Set the visual look of the dragged object
//Can be extended and customized. We use the default here.
View.DragShadowBuilder dragShadow = new View.DragShadowBuilder(v);
// Starts the drag, note: global flag allows for cross-application drag
v.startDragAndDrop(dragData, dragShadow, null, DRAG_FLAG_GLOBAL);
return false;
}
}