java - Android drag and drop on dynamically created views -


Really can do with some help

I have a random number of buttons built on the fly And each button is set on the Touch Listener, which works fine. Buttons are added to the Linearlayout (top) and there is another empty Linearlayout (bottom).

I want to be able to do the following:

  1. Drag & amp; Drop button between linerlight (top); Linearlayout (bottom)

      Expands the public class GetString activity {myDragEventListener mDragListen = new myDragEventListener (); Public Zero GetString (Reference Reference, String [] Temp, int no, LinearLayout words1, LinearLayout words2) {button bt; Int i = 0; (I = 0; i & lt; not; i ++) for {bt = new button (context); Bt.setId (i); Bt.setText (floating [i]); Bt.setOnTouchListener (new MyTouchListener ()); Words1.addView (BT); Bt.setOnDragListener (mDragListen); }} Protected class implements myDragEventListener Define a variable to type the action for View.OnDragListener {Public Boolean On Drag (see V, Dragravent Event) {// Incoming Event Final At Action = event.getAction () is; // handle every expected events switch (action) {case DragEvent.ACTION_DRAG_STARTED: return false; Case dragage Action_rag_ENTERED: v.invalidate (); Back true; Case dragage Action_rag_LOCATION: return true; Case dragage Action_RAAG_EXITED: v.invalidate (); Back true; Case dragage Action_DROP: Returns True; Case dragage Action_RAAG_ENDED: true back; // An unknown action type was received. Default: Log. E ("Drag drop example", "Unknown action type received by OnDrag Listener."); break; }      return false; }} See public class MyTouchListener applicable. OnTouchListener {@Override Public Boolean On-Touch (see V, MotionEvent arg1) {Clip data data = clip data. New plane text ("", ""); See. Drag shaftbuilder side = new view Drag shaftbuilder (v); V.startDrag (data, shadow, empty, 0); return false; }}}  


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -