Code example for DragEvent

Methods: getAction, getLocalState, getX, getY

0
	} 
 
	@Override 
	public boolean onDrag(View v, DragEvent event) {
		// Defines a variable to store the action type for the incoming event 
        final int action = event.getAction();
 
        // Handles each of the expected events 
        switch(action) {
 
            case DragEvent.ACTION_DRAG_STARTED:
                break; 
 
            case DragEvent.ACTION_DRAG_ENTERED: 
            	break; 
 
            case DragEvent.ACTION_DRAG_LOCATION:
            	break; 
 
            case DragEvent.ACTION_DRAG_EXITED:
            	break; 
 
           case DragEvent.ACTION_DROP:
        	   View view = (View) event.getLocalState();
        	   vaisseaux.add(new Enemy(view, view.getContentDescription().toString(), event.getX(), event.getY() + map.getY()));
        	   invalidate();
        	   break; 
 
           case DragEvent.ACTION_DRAG_ENDED:
        	   break;