【发布时间】:2018-02-06 03:42:23
【问题描述】:
我知道这听起来很奇怪,所以这是图片。
它保持正确的值。 (部分)选择了正确的单选按钮。 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);
}
});
EDIT1
EDIT2
布局:
<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>
【问题讨论】:
-
你指的是圆的中心没有圆点吗?如果是这样,您的主题是什么,您是否对
RadioButton的外观进行了自定义? -
@CommonsWare 是的,这就是我所指的!除了设置
colorPrimary和colorAccent之外,我没有对样式做任何事情。全部同步的时候我没有这个问题。 -
也许你扩展的主题使用白色选择点如果你使用深色主题切换到浅色,否则反之
-
当我手动选择它时,它工作正常。事件第二次触发时也是如此。
-
您是否尝试在主线程上使用
.observeOn(AndroidSchedulers.mainThread()).subscribe(...)处理它?
标签: android android-layout android-radiogroup android-radiobutton