View.onTouchEvent只注册ACTION_DOWN事件 [英] View.onTouchEvent only registers ACTION_DOWN event

查看:240
本文介绍了View.onTouchEvent只注册ACTION_DOWN事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我实现自定义的的TextView 和我想要做一些动作视图时感动。我想通了的onTouchEvent 方法会给我的全方位视图上的触摸,而无需使用 setOnTouchListener (I'想要做我所有的工作里面的观点,而不是在活动所以它的便携),但注册的唯一的触摸事件是 ACTION_DOWN 。如果我在活动使用此设置 OnTouchListener ,我得到了全方位的触摸事件,但的onTouchEvent 没有按'吨。

I'm implementing a custom TextView and I want to do some action when the view is touched. I figured the onTouchEvent method would give me the full range of touches on the view without having to use setOnTouchListener (I'm trying to do all my work inside the view instead of in the activity so it's portable), but the only touch event registered is ACTION_DOWN. If I set an OnTouchListener in the activity using this, I get the full range of touch events, but onTouchEvent doesn't.

谁知道为什么是这样的话,或者任何人都可以给我,不涉及使用的解决方案 setOnTouchListener (将prevent执行活动的设置自己的监听器)?

Anyone know why this is the case, or can anyone offer me a solution that doesn't involve using setOnTouchListener (Which would prevent the implementing activity from setting its own listener)?

推荐答案

您需要返回真下来后,得到以下的事件。

You need to return true to get the following events after a down.

这篇关于View.onTouchEvent只注册ACTION_DOWN事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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