samedi 23 mai 2015

Drag and Drop ImageView on ImageView Android

I want to be able to drag an imageview from a tablerow which is in a linearlayout and drop that imageview on another imageview in another tablerow which is in another linearlayout and then my first imageview to be disappeared. I use a touchlistener and a drag listener in separate classes.

 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);
            break;

and in my activity

TestImage1.setOnTouchListener(new MyTouchListener());
view.findViewById(R.id.LinearChoices).setOnDragListener(new MyDragListener(view.getContext()));
view.findViewById(R.id.LinearBucket).setOnDragListener(new MyDragListener(view.getContext()));

How can I implement the dragging of an imageview dissappearing when dropped on another imageview

Aucun commentaire:

Enregistrer un commentaire