如果我在 OnTouchListener 中返回 false,实际会发生什么?

编程入门 行业动态 更新时间:2024-10-09 22:20:04
本文介绍了如果我在 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,实际会发生什么?

本文发布于:2023-06-02 19:21:11,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/457500.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:我在   发生   OnTouchListener   false

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!