How to detect a motion event when an onClick listener is there?

非 Y 不嫁゛ 提交于 2020-01-04 14:01:06

问题


I have a ListView with onItemClick() method . Now I want to detect a touch motion in the screen . Implementing onTouchEvent() does not work in this case since I have written already a click listener . So help me how to do it. I need both the on click listener and onTouchEvent().


回答1:


You need to implement the OnTouchListener(View v, MotionEvent event) to check event.getX() and event.getY() when event.ACTION_DOWN and event.ACTION_UP and compare them to know the motion direction.

Note: you must return true to be able to receive the event.ACTION_UP event.



来源:https://stackoverflow.com/questions/8339761/how-to-detect-a-motion-event-when-an-onclick-listener-is-there

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!