如何将列表视图项目拖放到另一个列表视图

发布于 2024-10-26 20:51:13 字数 1059 浏览 5 评论 0原文

嗨,我是 Raynast,我是 Android 编程新手 现在我的项目中有一个关于Listview拖放的小问题

我决定从数据库布局到三个Listview查询

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

我使用android平台2.3.1

我想将item1从Listview1拖动到liewview2或liewview3 并在 listviewitem 之间放置

我尝试研究解决方案来解决这个问题,但我没有找到!

观察: MotionEvent 有action_up action_down 没有action_right,left

我想知道解决此问题的解决方案 如果不可能请告诉我或提出另一种方法来进行此活动,请

提前致谢

您的回复对我和另一个人非常有用

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

尘曦 2024-11-02 20:51:13

您好,我正在 github 中开发一个示例 https://github.com/mtparet/ Drag-And-Drop-Android

它可以帮助你。

欢迎所有贡献

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

栩栩如生 2024-11-02 20:51:13

看一下这个在列表视图中拖放的示例。

拖放示例...单击您可以在此处找到该项目。并下载 Zip 文件..

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..

离线来电— 2024-11-02 20:51:13

MotionEvent.getAction() 返回的 ACTION_UPACTION_DOWN 常量指的是手指点击的状态(例如,手指放在屏幕上) ,手指从屏幕上抬起),而不是移动方向。您还需要将 MOVE 操作与 ACTION_UPACTION_DOWN 结合使用来完成您想要执行的操作。

例如,在您的 onTouch 方法中,当您收到 MOTION_DOWN (用户按下了 ListView 项目)时,请识别用户点击了哪个项目。然后,您可以跟踪 MOVE 操作以提供视觉提示,例如绘制跟随手指的浮动“幽灵”版本的项目。最后,当您收到 MOTION_UP (用户在拖动后抬起手指)时,请确定他们的手指位于哪一列,并执行您需要执行的操作将数据移至另一个列表。

您可以使用每个 MotionEvent 提供的 x 和 y 坐标来确定诸如用户点击了哪个项目、他们将手指移到哪个列表等信息。

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.

萌能量女王 2024-11-02 20:51:13

希望 http://techdroid.kbeanie.com/2011/10/ Drag-and-drop-honeycombics.html 这将在一定程度上解决你的问题,但仍然没有得到完美的解决方案......

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....

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文