如何实现在Android的列表之间拖动和下降?

编程入门 行业动态 更新时间:2024-10-18 12:35:19
本文介绍了如何实现在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的列表之间拖动和下降?

本文发布于:2023-11-22 14:46:49,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1617865.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:拖动   如何实现   列表   Android

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!