的onClick片段里呼吁活动 [英] onClick inside fragment called on Activity

查看:99
本文介绍了的onClick片段里呼吁活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是封装的东西转换成一个分段的时刻,碰到一个问题,就是很难谷歌。 在我的片段与属性的onClick一些按钮,但他们是所谓的活动,而从Android系统的碎片 - 这使得封装有点笨拙。有没有办法让从的onClick反射的东西的片段上打电话?唯一的解决这个我目前看到的不是通过code使用的onClick在XML和设置点击听众片段里面。

i am encapsulating stuff into a fragment at the moment and run into a problem that is hard to google. Inside my fragment are some buttons with onClick attributes but they are called on the Activity rather the fragment from the android system - this makes encapsulating a bit clumsy. Is there a way to have the reflection stuff from onClick to call on the fragment? The only solution to this I see at the moment is not to use onClick in the xml and set click-listeners inside the fragment via code.

推荐答案

我跟谷歌的一些@#adl2011 - 他们认识到这个问题,也许会出现在未来的修补程序。在此之前 - 一个人应该在片段使用.setOnClick

I spoke to some googlers @ #adl2011 - they recognize the problem and perhaps there will be a fix of that in the future. Until then - one should use .setOnClick in the Fragment.

这篇关于的onClick片段里呼吁活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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