【发布时间】:2018-11-28 18:17:17
【问题描述】:
我在 recyclerview 中创建了 4 个单选按钮,但是当我选中一个单选按钮时,它已选中,但当我选中另一个单选按钮时,第一个单选按钮无法取消选中
holder.cb_votes.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
for (int i = 0; i < pollItems.size(); i++) {
if (isChecked) {
holder.cb_votes.setChecked(true);
} else {
holder.cb_votes.setChecked(false);
}
}
}
});
这是我的xml
<RadioGroup
android:id="@+id/rg_cb_votes"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.5">
<RadioButton
android:id="@+id/cb_votes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="3dp"
android:text="Yes"
android:textSize="12dp" />
</RadioGroup>
【问题讨论】:
-
创建 RadioGroup,并在 RadioGroup 中添加单选按钮
-
您使用单选按钮进入单选组。
-
我已经使用单选组来单选按钮
标签: android radio-button