如何检测运动事件时onClick的监听器呢? [英] How to detect a motion event when an onClick listener is there?

查看:105
本文介绍了如何检测运动事件时onClick的监听器呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个的ListView onItemClick()方法。现在我想检测屏幕触摸动作。实施 onTouchEvent()不会在这种情况下,因为我已经写了一个点击监听工作。那么帮助我如何做到这一点。我既需要在点击监听器和 onTouchEvent()

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().

推荐答案

您需要实现OnTouchListener(视图V,MotionEvent事件)来检查event.getX()和event.getY()的时候event.ACTION_DOWN和事件。 ACTION_UP并加以比较了解的运动方向。

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.

注意:您必须返回true,以能够接收event.ACTION_UP事件

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

这篇关于如何检测运动事件时onClick的监听器呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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