我正在使用以下代码在运行时创建一个带有单选按钮(来自枚举)的单选组。
RadioGroup radioGroup = new RadioGroup(this);
List<LocationTypeEnum> warningTypes = preferences.getWarningTypes();
for (LocationTypeEnum enumElement : warningTypes) {
RadioButton radio = new RadioButton(this);
radio.setText(enumElement.toString());
//Check one specific radio by default
radio.setChecked(enumElement.intValue == userDefinedLocation.getType().intValue);
radioGroup.addView(radio, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));
}
当谈到屏幕并且我尝试更改收音机时,这两个选项都保持选中状态:
怎么了?