如果Android中的同一个视图组中的事件从一个小孩转移到另一个小孩,该怎么办? [英] How can I transfer event from one child to another child if they are from same viewgroup in android?

查看:169
本文介绍了如果Android中的同一个视图组中的事件从一个小孩转移到另一个小孩,该怎么办?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

到目前为止,我能够将事件从父(视图组)转移到小孩。即当我点击孩子1时,视图组将事件发送给孩子1,当我单击孩子2(位于小孩1下)时,视图组将事件发送给孩子2.

So far I was able to transfer the event from the parent (viewgroup) to the child. ie When I click child 1, the viewgroup sends the event to child 1 and when I click child 2 (which is under child 1), the viewgroup sends the event to child 2.

问题:我想要做的是,当应用程序处于特定状态,并且单击了小孩2时,我希望视图组将事件发送到子级1而不是小孩2.

Problem: What I wanted to do was, When app is in certain state and child 2 is clicked I want the viewgroup to send the event to child 1 instead of child 2.

到目前为止:这个链接类型触及问题,但不在android中。

So far : This link kind of touches the issue but is not in android.

推荐答案

这样的一个东西:
在主视图组

Something like this : In main viewgroup

child2.setOnClickListener(new....{

and inside this event handler call an appropriate method in child1 

child1.onSomethingInChild2()

这篇关于如果Android中的同一个视图组中的事件从一个小孩转移到另一个小孩,该怎么办?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆