Code example for DragEvent

Methods: getAction, getLocalState

0
				R.drawable.shape_droptarget); 
		Drawable normalShape = getResources().getDrawable(R.drawable.shape);
 
		@Override 
		public boolean onDrag(View v, DragEvent event) {
			int action = event.getAction();
			switch (event.getAction()) {
			case DragEvent.ACTION_DRAG_STARTED:
				// Do nothing 
				break; 
			case DragEvent.ACTION_DRAG_ENTERED:
				v.setBackgroundDrawable(enterShape);
				break; 
			case DragEvent.ACTION_DRAG_EXITED:
				v.setBackgroundDrawable(normalShape);
				break; 
			case DragEvent.ACTION_DROP:
				// Dropped, reassign View to ViewGroup 
				View view = (View) event.getLocalState();
				ViewGroup owner = (ViewGroup) view.getParent();
				// TODO 1 removeView from owner 
				// TODO 2 add to v which is a LinearLayout 
				// TODO 3 set view to View.Visible