Android的ListView的onTouchEvent不给ACTION_DOWN [英] Android ListView onTouchEvent doesn't give ACTION_DOWN
问题描述
为了让列表重新排序功能我转身<一个href=\"http://ericharlow.blogspot.de/2010/10/experience-android-drag-and-drop-list.html?showComment=1332171356419#c7022544393803712338\"相对=nofollow>这个实现。
In order to have list reordering functionality I turned to this implementation.
我的问题是,当我尝试在我的ListView拖动一个项目,我没有得到ACTION_DOWN事件。相反,对于单个涂抹上下运动,我得到2 ACTION_MOVE事件(行动= 0x00000002)和一个ACTION_UP事件(行动= 00000001)的顺序。
My problem is that when I try to drag an item in my ListView, I don't get the ACTION_DOWN event. Instead, for a single smear down motion I get 2 ACTION_MOVE events (action=0x00000002) and a single ACTION_UP event (action=0x00000001) in this order.
我看过类似的问题,但好像每个人都有相反的问题,只得到ACTION_DOWN事件。
谁能想到为什么会这样呢?
I've looked at similar questions but it seems like everyone has the opposite problem, getting only ACTION_DOWN events. Can anyone think of why this is happening?
谢谢,
约尔
推荐答案
原来我需要添加这一小块code的:
It turns out I needed to add this small piece of code:
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
return super.onInterceptTouchEvent(ev);
}
现在,我得到了OnTouchEvent功能ACTION_DOWN事件,这一切工作正常。
Now I get the ACTION_DOWN events in the OnTouchEvent function and it all works fine.
这篇关于Android的ListView的onTouchEvent不给ACTION_DOWN的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!