如何实现在Android的列表之间拖动和下降? [英] How to implement drag-and-drop between lists in android?

查看:111
本文介绍了如何实现在Android的列表之间拖动和下降?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让这个用户可以从一个列表视图中拖动一个TextView,然后将其拖放到另一个,而且我发现它是非常困难的。结果
到目前为止,我发现最大的问题是,onTouchEvents似乎只在认为ACTION_DOWN事件起源于被听到。我将在一个列表中点击并ACTION_DOWN在那里听到的。然后,我将拖动名单之外,让去了另一个列表。但onTouchEvent只被要求对原来的名单,无论我要去哪里。我认为这将是作为监听在接收列表中的ACTION_UP事件一样简单;但是这就是所谓的,即使我外面原来的名单上。

I'm trying to make it so that the user can drag a textview from one listview and then drop it into another, and I'm finding it to be very difficult.
The biggest problem I have found so far is that onTouchEvents seem to only be heard in the view that the ACTION_DOWN event originated in. I'll click in one list and the ACTION_DOWN is heard in there. Then I'll drag outside the list and let go over another list. But the onTouchEvent is only being called for the original list, no matter where I'm going. I thought it was going to be as simple as listening for an ACTION_UP event in the receiving list; but that's called on the original list even though I'm outside it.

我至今是有点乱。当onLongTouchEvent被调用时,名单告诉的主要活动开始拖动draggableTextView(其中有一个的moveTo方法)。由于移动事件继续原来的名单上叫,我有它不断地设置该draggableTextView的位置。但我不能把它插入到另一个列表,因为我想不出什么我放手之上。

What I have so far is a bit messy. When onLongTouchEvent is called, the list tells the main activity to start dragging a draggableTextView (which has a moveTo method). Since the move events continue to be called on the original list, I have it continually setting the position of this draggableTextView. But I can't insert it into another list because I can't figure out what I'm letting go on top of.

推荐答案

是的,你说得对,这不是一件容易的事。然而,它是可能的:你可以检查commonsguy的 CWAC-touchlist 例如

Yes, you are right, this is not an easy task. However it is possible: you might check commonsguy's cwac-touchlist example.

这篇关于如何实现在Android的列表之间拖动和下降?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆