How to Drag drop Listview item to another Listview
Asked Answered
G

4

12

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 query from database

     _________________________
     |list_1 |list_2 |list_3 |
     |_______|_______|_______|
     |_______|_______|_______|
     ||     |||     |||     ||
     ||item1|||item5|||item8||
     ||_____|||_____|||_____||
     |_______|_______|_______|
     ||     |||     |||     ||
     ||item2|||item6|||item9||
     ||_____|||_____|||_____||
     |_______|_______|       |
     ||     |||     ||       |
     ||item3|||item7||       |
     ||_____|||_____||       |
     |_______|       |       |
     ||     ||       |       |
     ||item4||       |       |
     ||_____||       |       |
     |_______|_______|_______|

I use android platform 2.3.1

I want to Drag item1 from Listview1 to liewview2 or liewview3 and drop between listviewitem

I try to research solution to resolve this problem but I'm not found!

Observations : MotionEvent have action_up action_down don't have action_right,left

I want to know solution to resolve this problem If it not possible tell me or propose another method to make this activity please

Thank in advance

Your response will be very useful for me and another one

Germano answered 25/3, 2011 at 19:50 Comment(1)
Dear raynast, Have you got any solution of this ?Onset
M
3

Hello I'm developing an example of this in github https://github.com/mtparet/Drag-And-Drop-Android

It could help you.

All contribution are welcome

Molini answered 30/5, 2011 at 14:46 Comment(0)
P
2

Take a look at this sample that Drag and drop inside a List View..

Drag and drop sample...Click on You can find the project here. and Download the Zip file..

Phyllida answered 26/3, 2011 at 13:52 Comment(1)
Thank for your answer I'm try to read this code but I'm don't know way to create more listviewGermano
O
1

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.

Oxidize answered 26/3, 2011 at 2:15 Comment(1)
Thank a lot Now I understood about Action_up and down but I can't apply it to my project if you have example code Draganddrop listView help me Plz.Germano
O
0

hope http://techdroid.kbeanie.com/2011/10/drag-and-drop-honeycombics.html this will solve your problem up to some extend but still not got the perfect solution....

Octopod answered 2/8, 2013 at 11:56 Comment(1)
Welcome to Stack Overflow. Please summarise the link in your answer; that way, if the link goes stale the answer won't be completely useless.Unhallowed

© 2022 - 2024 — McMap. All rights reserved.