Returning true and false in OnTouch?

梦想的初衷 提交于 2019-12-19 03:46:44

问题


Does it matter if i return true or false in onTouch() of an OnTouchListener? I can't see any difference between returning true or false in this example: Android Swipe on List


回答1:


The return value determines if you consumed the touch event.

In other words true means that this touch event is interesting to you and all follow up calls of this touch event like ACTION_MOVE or ACTION_UP will be delivered to you.

If you return false than the touch event will be passed to the next View further up in the view hierarchy and you will receive no follow up calls. The touch event will continue to be passed further up the view hierarchy until someone consumes it.

If you have any further questions please feel free to ask!



来源:https://stackoverflow.com/questions/24287292/returning-true-and-false-in-ontouch

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