The order of click event handled by parent view and child view

别来无恙 提交于 2020-01-06 14:55:11

问题


I have been working on android development for a while, but I am still confused about this question..

From android documentation said, the event will start from root view, and dispatched to the child view. Which means viewgroup should get touch event before view(which is its child), but from what I have debugged, this is not the case...

I create a RadioGroup, then add three radiobutton into it, every time when I click radiobutton, its click event is triggered. Radiogroup's click event is not even fired...

How can we explain this?

Any idea? Thanks.


回答1:


When a child handles the onClick, the parent does not receive the event. If you want to see the parent get the event, don't set an onClickListener on the child.

onTouch events are handled a bit differently.



来源:https://stackoverflow.com/questions/5598320/the-order-of-click-event-handled-by-parent-view-and-child-view

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