在Android Firebase中,要从单选按钮中获取值时出现错误的解决方法如下所示:
implementation 'com.google.firebase:firebase-database:19.6.0'
private RadioGroup radioGroup;
private RadioButton radioButton;
// 在onCreate方法或适当的位置初始化radioGroup
radioGroup = findViewById(R.id.radioGroup);
// 在需要获取单选按钮的值的地方
int selectedId = radioGroup.getCheckedRadioButtonId();
radioButton = findViewById(selectedId);
String selectedValue = radioButton.getText().toString();
注意事项: