在Android开发中,我们经常会对一个View设置onClick,onLongClick,onTouch事件,有时还会同时设置这三个事件,那么在同时设置这三个时候,执行顺序是什么样呢?
首先,官方文档上面对onLongClick()和onTouch()的描述如下:
onLongClick() - This returns a boolean to indicate whether you have consumed the event and it should not be carried further. That is, return true to indicate that you have handled the event and it should stop here; return false if you have not handled it and/or the event should continue to any other on-click listeners.
大致意思就是:onLongClick()方法会返回一个boolean值,如果是true,表示已经处理了此事件,不需要继续传递;如果是false,表示没有处理,事件会继续到其他的监听事件。
onTouch() - This returns a boolean to indicate whether your listener consumes this event. The important thing is that this event can have multiple actions that follow each other. So, if you return false when the down action event is received, you indicate that you have not consumed t