Android DragEvent - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android DragEvent class.

This code example shows how to use the following methods: getAction, getClipData
        } 
 
        @Override 
        public boolean onDragEvent(DragEvent event) {
            if (DEBUG) Slog.d(TAG, "onDragEvent: " + event);
            switch (event.getAction()) {
                // We want to appear whenever a potential drag takes off from anywhere in the UI. 
                case DragEvent.ACTION_DRAG_STARTED:
                    show(true); 
                    break; 
                case DragEvent.ACTION_DRAG_ENTERED:
                    if (DEBUG) Slog.d(TAG, "entered!");
                    // XXX: TODO 
                    break; 
                case DragEvent.ACTION_DRAG_EXITED:
                    if (DEBUG) Slog.d(TAG, "exited!");
                    break; 
                case DragEvent.ACTION_DROP:
                    if (DEBUG) Slog.d(TAG, "dropped!");
                    mPocket.stash(event.getClipData());

7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: getAction, getClipData, getLocalState, getX, getY
	} 
 
	@Override 
	public boolean onDrag(View v, DragEvent event)
	{ 
		switch (event.getAction())
		{ 
		case DragEvent.ACTION_DRAG_STARTED: 
			Log.d("drag", "registered");
			break; 
			 
		case DragEvent.ACTION_DRAG_ENTERED:
				 
			break; 
 
		case DragEvent.ACTION_DRAG_LOCATION:
			break; 
 
		case DragEvent.ACTION_DRAG_ENDED:
			 

6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: getAction, getLocalState, getX, getY
    } 
	 
	private class PlaceDragListener implements OnDragListener {
		@Override 
		public boolean onDrag(View v, DragEvent event) {
			switch (event.getAction()) {
			    case DragEvent.ACTION_DROP:
			    	Toast.makeText(contextt, "ACTION_DROP", Toast.LENGTH_LONG).show();
			    	View view = (View) event.getLocalState();
			    	ViewGroup owner = (ViewGroup) view.getParent();
			    	owner.removeView(view);
			    	 
			    	FrameLayout container = (FrameLayout) v.getParent();
			        container.addView(view);
			        container.bringChildToFront(view);
			        view.setX((int)event.getX() + 5 - view.getWidth() / 2);
			        view.setY((int)event.getY() + 5 - view.getHeight() / 2);
			        view.setVisibility(View.VISIBLE);			        
			        break; 
			    default : 

6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: getAction, getClipData, getX, getY
    	    private static final String DROPTAG = "DropTarget";
    		private int dropCount = 0;
			private ObjectAnimator anim;
 
			public boolean onDrag(View v, DragEvent event) {
				int action = event.getAction();
				boolean result = true;
				switch(action) {
				case DragEvent.ACTION_DRAG_STARTED:
					Log.v(DROPTAG, "drag started in dropTarget");
		            break; 
				case DragEvent.ACTION_DRAG_ENTERED:
					Log.v(DROPTAG, "drag entered dropTarget");
				    anim = ObjectAnimator.ofFloat((Object)v, "alpha", 1f, 0.5f);
				    anim.setInterpolator(new CycleInterpolator(40));
				    anim.setDuration(30*1000); // 30 seconds
				    anim.start();
		            break; 
				case DragEvent.ACTION_DRAG_EXITED:
					Log.v(DROPTAG, "drag exited dropTarget");

6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: getAction, getClipData, getX, getY
			private static final String DROPTAG = "DropTarget";
			private int dropCount = 0;
			private ObjectAnimator anim;
 
			public boolean onDrag(View v, DragEvent event) {
				int action = event.getAction();
				boolean result = true;
				switch (action) {
				case DragEvent.ACTION_DRAG_STARTED:
					Log.v(DROPTAG, "drag started in dropTarget");
					break; 
				case DragEvent.ACTION_DRAG_ENTERED:
					Log.v(DROPTAG, "drag entered dropTarget");
					anim = ObjectAnimator
							.ofFloat((Object) v, "alpha", 1f, 0.5f);
					anim.setInterpolator(new CycleInterpolator(40));
					anim.setDuration(30 * 1000); // 30 seconds
					anim.start();
					break; 
				case DragEvent.ACTION_DRAG_EXITED:

6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE

Related Android DragEvent Questions & Answers:

Other Android DragEvent Examples

49:	
50:	    @Override
51:	    public boolean onDrag(View v, DragEvent event) {
52:	      int action = event.getAction();
53:	      switch (event.getAction()) {

Read More

See Code Examples for Android DragEvent Methods: