【发布时间】:2021-10-11 21:08:34
【问题描述】:
我正在尝试从组中选定的单选按钮中获取文本。我已经搜索过同样的问题,但我得到的解决方案仍然让我遇到同样的错误。
2021-08-07 11:14:14.464 7297-7297/com.findplaceslaxco.ecommerce W/System.err: at com.findplaceslaxco.ecommerce.Adapters.SecondCartAdapter$ViewHolder$2$1.onCheckedChanged(SecondCartAdapter.java:276)
这是代码:
mRadioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
if (checkedId != -1){
MaterialRadioButton radioButton = (MaterialRadioButton) group.findViewById(checkedId);
boolean isChecked = radioButton.isChecked();//this is where the error appears
}
}
}
});
【问题讨论】:
-
试试看这个StackOverflow链接它会帮助你
-
谢谢大家的回复,我发现虽然仍然显示单选按钮,但 childrenCount 组是零。