将多个听众意见的Andr​​oid? [英] Attaching multiple listeners to views in android?

查看:133
本文介绍了将多个听众意见的Andr​​oid?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以将多个的onClick监听器按钮的android? 例如:

Is it possible to attach multiple onClick listeners to buttons in android? Example:

btn1.setOnClickListener(listener1);
btn1.setOnCliclListener(listener2);

和被点击的onClick事件的按钮时,无论 listener1 LISTENER2 被触发?

And when the button is clicked onClick event of both listener1 and listener2 are triggered?

在正常的GUI应用程序,我知道,我们可以将多个事件处理程序的事件。是否有可能为Android也还是有什么限制吗?

In normal GUI applications I know that we can attach more than one event handler for an event. Is it possible for android too or is there any restrictions?

问候, Lalith

Regards, Lalith

推荐答案

Android的只支持一般的注册监听器。但是,你可以轻松地创建一个侦听器,只需转发活动,使用复合模式其他的侦听器。

Android only supports one registered listener in general. However, you can easily create a listener that simply forwards the events to other listeners using the composite pattern.

这篇关于将多个听众意见的Andr​​oid?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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