我试图让这个用户可以从一个列表视图中拖动一个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的列表之间拖动和下降?
发布评论