android - Drag & Drop without removal from owner -


I'm using it on a rainy layer with three textured drag and drop to move it to another container. My code:

  OnDragListener dragi = new OnDragListener () {@Override Public Boolean OnDrag (see ARB0, DragEvent arg1) {// TODO auto generated stub int action = arg1.getAction () ; Switch (action) {case drag event Action_rag_STARTED: break; Case dragage Action_rag_ENTERED: break; Case dragage Action_rag_EXITED: break; Case dragage Action_DROP: View View = (see) arg1.getLocalState (); ViewGroup Owner = (ViewGroup) view.getParent (); Owner.removeView (see); // liner layout container = (linear layout) arg0; Container.addView (see); View.setVisibility (View.VISIBLE); } break; Case dragage Action_rag_ENDED: break; Default: Break; } Back true; }};   

My problem is that I do not want to delete the view from the base container, it should remain there and just add a copy in the second container.

Thx

Any view should be the only parent in any given moment What you can do on your drag instead, create a clone of the scene leaving the view in the new container and add a new container to it.

To Clone a View: If Your View = & gt; Button is called myButton, so you can:

  button myButtonClone = new button (reference); MyButtonClone.setText (myButton.getText ());   

You will have a clone of the original button. This applies to every other property, if you want to make a clone of an image, just create a new one and set it to be one of the first image view.

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -