如果我在OnTouchListener中返回false,实际上会发生什么? [英] What actually happens if I return false in a OnTouchListener?

查看:194
本文介绍了如果我在OnTouchListener中返回false,实际上会发生什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个需要SurfaceView才能实现OnTouchListener的游戏.在游戏过程中,我想在特定时间内暂停监听器.我尝试从onTouch()方法返回false,但该方法仍然保持执行状态.还有其他方法可以使监听器暂停一段时间吗?任何人都请解释从onTouch()返回false的实际含义是什么?

I am creating a game that requires a SurfaceView to implement OnTouchListener. During the game I want to pause the Listener for some specific time.I tried returning false from the onTouch() method , but still the method keeps executing.Is there any other way to have the listener paused for sometime? And anyone please explain what returning false from onTouch() actually mean?

推荐答案

来自查看文档:

Returns
True if the listener has consumed the event, false otherwise.

如果返回true,则告诉android印刷机已处理完毕.算了吧.

If you return true you tell android that the press is taken care of. Forget it.

如果您返回false,您基本上会说不是我的问题,请其他人来处理此点击".然后android会将事件传递给其他视图,这些视图可能在您的视图下.

If you return false you basically say "Not my problem, Someone else will have to take care of this click". Then android will pass the event down to other views, which could be under your view.

这篇关于如果我在OnTouchListener中返回false,实际上会发生什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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