父视图和子视图处理点击事件的顺序
我从事android开发已经有一段时间了,但我仍然对这个问题感到困惑。
从android文档中说,事件将从根视图开始,并分派到子视图。 这意味着视图组应该在视图(它的子视图)之前获取触摸事件,但从我调试的情况来看,情况并非如此...
我创建一个RadioGroup,然后向其中添加三个单选按钮,每次单击单选按钮时,它的点击事件被触发。 Radiogroup 的点击事件甚至没有被触发...
我们该如何解释这一点?
有什么想法吗?谢谢。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当子进程处理 onClick 时,父进程不会收到该事件。如果您想看到父级获取事件,请不要在子级上设置 onClickListener。
onTouch 事件的处理方式略有不同。
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.