Code example for DragEvent

Methods: getAction, getLocalState

0
	public boolean onDrag(View v, DragEvent event) {
//		img1 = (ImageView) findViewById(R.id.myimage1); 
//		img2 = (ImageView) findViewById(R.id.myimage2); 
//		img3 = (ImageView) findViewById(R.id.myimage3); 
 
		int action = event.getAction();
		switch (event.getAction()) {
		case DragEvent.ACTION_DRAG_STARTED:
			// Do nothing 
			break; 
		case DragEvent.ACTION_DRAG_ENTERED:
//			v.setBackgroundDrawable(enterShape); 
			System.out.println("ACTION_DRAG_ENTERED:");
			break; 
		case DragEvent.ACTION_DRAG_EXITED:
//			v.setBackgroundDrawable(normalShape); 
			System.out.println("ACTION_DRAG_EXITED:");
			break; 
		case DragEvent.ACTION_DROP:
			// Dropped, reassign View to ViewGroup 
			View view = (View) event.getLocalState();
			ViewGroup owner = (ViewGroup) view.getParent();
			owner.removeView(view);
			LinearLayout container = (LinearLayout) v;
			container.addView(view);
			view.setVisibility(View.VISIBLE);