我知道这听起来很奇怪,所以这里有一张图片。
它保留了正确的值。正确的单选按钮被(部分)选中。所有 OnCheckedChangeListener
中的逻辑都被正确执行。我完全惊呆了。为什么单选按钮没有完全被选中?
我唯一能想到的是我正在使用 Rx2Firebase
。
periodRetriever = FirebaseHelper.getInstance(getContext()).getPeriod()
.defaultIfEmpty(0)
.distinctUntilChanged()
.subscribe(new Consumer<Integer>() {
@Override
public void accept(@NonNull Integer headerType) throws Exception {
getRadioViewChecked(headerType).setChecked(true);
}
});
编辑1
编辑2
布局:
<RadioGroup
android:id="@+id/rgPeriod"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<android.support.v7.widget.AppCompatRadioButton
android:id="@+id/rbMonth"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="false"
android:text="@string/month" />
<android.support.v7.widget.AppCompatRadioButton
android:id="@+id/rbWeek"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="false"
android:text="@string/week" />
<android.support.v7.widget.AppCompatRadioButton
android:id="@+id/rb4Weeks"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="false"
android:text="@string/four_weeks" />
</RadioGroup>
.observeOn(AndroidSchedulers.mainThread()).subscribe(...)
在主线程中处理它吗? - Kirill