【发布时间】:2015-05-12 01:51:17
【问题描述】:
我正在关注Qiitanium 应用程序的代码(请参阅链接中突出显示的行),但我无法弄清楚如何绑定 RadioButtons
假设我有一个 R.id.rgMyButtons 作为 Id 的 RadioGroup,它包含 3 个 RadioButtons “Dead”、“Alive”、“Body Missing”,ID 分别是 R.id.rbDead、R.id.rbAlive、R。 id.rbMissing
我将 RadioGroup 字段设置为
Rx<RadioGroup> radioGroup;
我将 onViewCreated 中的视图设置为
rdGroup = RxView.findById(this, R.id.rgMyButtons);
rdGroup.get().setOnCheckedChangeListener(mOnPersonStateUpdateListener);
在 onBind 中,我想将 RadioGroup 绑定到模型数据,以便返回的值直接映射到该组中正确的 RadioButton。我正在寻找类似的东西
rdGroup.bind(person.state(), RxActions.someAction()),
使其绑定到 RadioGroup 并自动设置正确的值。
person_state() 实际上返回 2 代表死亡,3 代表活着,4 代表失踪,我希望检查 RadioGroup 中的正确字段。如何在 RxAndroid 中实现这一点?
【问题讨论】:
标签: android rx-java radio-group rx-android