How to Drag drop Listview item to another Listview

前端 未结 4 1703
清歌不尽
清歌不尽 2020-12-09 19:14

Hi I\'m Raynast I\'m a newbie for Android Programming Now I have a little problem from my project about Listview Drag and Drop

I decide layout to Three Listview quer

4条回答
  •  执念已碎
    2020-12-09 19:41

    The ACTION_UP and ACTION_DOWN constants returned by MotionEvent.getAction() refer to the state of finger taps (for example, finger is placed down on screen, finger is lifted up from screen), not to movement direction. You will need to also use the MOVE action in combination with ACTION_UP and ACTION_DOWN to accomplish what you're trying to do.

    For example, in your onTouch method, when you receive MOTION_DOWN (user has pressed down on the ListView item), identify which item the user tapped on. You can then track the MOVE action to give visual cues, such as to draw a floating "ghost" version of the item that follows their finger. Finally, when you receive MOTION_UP (user lifted their finger after dragging), identify which column their finger was over and do whatever you need to do to move the data over to the other list.

    You can use the x and y coordinates provided with each MotionEvent to determine things like which item the user tapped on, which list they moved their finger over, etc.

提交回复
热议问题