问题
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