Code example for DragEvent

Methods: getAction, getLocalState, getX, getY

0
	 
	private class ChoiceDragListener implements OnDragListener {
 
		@Override 
		public boolean onDrag(View v, DragEvent event) {
			switch (event.getAction()) {
			case DragEvent.ACTION_DRAG_STARTED:
				// no action necessary 
				break; 
			case DragEvent.ACTION_DRAG_ENTERED:
				// no action necessary 
				break; 
			case DragEvent.ACTION_DRAG_EXITED:
				// no action necessary 
				break; 
			case DragEvent.ACTION_DROP:
 
				// get the original text view 
				TextView view = (TextView) event.getLocalState();
				int position = dropzone.pointToPosition((int) event.getX(),
						(int) event.getY());
				ListItem item = new ListItem((ListItemType) view.getTag());
				try { 
					adapter.insert(item, position);
				} catch (IndexOutOfBoundsException e) {
					adapter.add(item);