How I can create a copy of ImageView on Drad and Drop? I searched in google, but i don't found nothing.
Please, help me.
Here's a full example that appears to do most of what you want to do. It appears the only change required is to create a new ImageView and copy the bitmap into it.To do that, you'd need to alter the onDrag() method of the class MyDragListener to be something like this:
case DragEvent.ACTION_DROP:
// Dropped, reassign View to ViewGroup
View view = (View) event.getLocalState();
//ViewGroup owner = (ViewGroup) view.getParent(); // Removed
//owner.removeView(view); // Removed
LinearLayout container = (LinearLayout) v;
// Added the following to copy the old view's bitmap to a new ImageView:
ImageView oldView = (ImageView) view;
ImageView newView = new ImageView(getApplicationContext());
newView.setImageBitmap(((BitmapDrawable) oldView.getDrawable()).getBitmap());
container.addView(newView); // Changed to add new view instead
view.setVisibility(View.VISIBLE);
break;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With