Code example for DragEvent

Methods: getAction, getClipData

0
	 
	protected class MyDragEventListener implements View.OnDragListener {
 
		@Override 
		public boolean onDrag(View v, DragEvent event) {
			final int action = event.getAction();
			 
			switch(action) {
			case DragEvent.ACTION_DRAG_STARTED:
				//All involved view accept ACTION_DRAG_STARTED for MIMETYPE_TEXT_PLAIN 
             /*   if (event.getClipDescription() 
                		.hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN)) 
                { 
                	commentMsg += v.getTag() 
                			+ " : ACTION_DRAG_STARTED accepted.\n"; 
                	comments.setText(commentMsg); 
                	return true;	//Accept 
                }else{ 
                	commentMsg += v.getTag() 
                			+ " : ACTION_DRAG_STARTED rejected.\n"; 
                	comments.setText(commentMsg); 
                	return false;	//reject 
                }*/ 
			case DragEvent.ACTION_DRAG_ENTERED:
			/*	commentMsg += v.getTag()	+ " : ACTION_DRAG_ENTERED.\n"; 
				comments.setText(commentMsg);*/ 
				return true; 
			case DragEvent.ACTION_DRAG_LOCATION:
			/*	commentMsg += v.getTag()	+ " : ACTION_DRAG_LOCATION - " 
					+ event.getX() + " : " + event.getY() + "\n"; 
				comments.setText(commentMsg);*/ 
				return true; 
			case DragEvent.ACTION_DRAG_EXITED:
			/*	commentMsg += v.getTag()	+ " : ACTION_DRAG_EXITED.\n"; 
				comments.setText(commentMsg);*/ 
				return true; 
			case DragEvent.ACTION_DROP:
				// Gets the item containing the dragged data 
                ClipData.Item item = event.getClipData().getItemAt(0);
 
              /*  commentMsg += v.getTag() + " : ACTION_DROP" + "\n"; 
				comments.setText(commentMsg);*/ 
				 
				//If apply only if drop on buttonTarget