У меня есть радиогруппа, которая загружает вопросы в зависимости от ответа из предыдущего набора вопросов. Это одна и та же радиогруппа, меняются только вопросы.Очистить radioGroup.getCheckedRadioButtonId() из группы радио
Вот код, в котором я загружаю вопросы;
if (key.substring(0,2).equalsIgnoreCase("CS")){
actionText.setVisibility(View.GONE);
radioGroup.setVisibility(View.VISIBLE);
radioGroup.removeAllViews();
btnForward.setEnabled(true);
Set optTextset=thisScreenOpts.lhmOptionText.entrySet();
Set optAnswerSet=thisScreenOpts.lhmNextStep.entrySet();
Iterator i=optTextset.iterator();
Iterator i2=optAnswerSet.iterator();
if (thisScreenOpts.title!=null){
myText.setText(thisScreenOpts.title);
}else{
myText.setText("");
}
while (i.hasNext()){
Map.Entry optTextMap=(Map.Entry)i.next();
Map.Entry optAnswerMap=(Map.Entry)i2.next();
RadioButton radioButton=new RadioButton(this);
radioButton.setTag(optAnswerMap.getValue().toString());
radioButton.setText(optTextMap.getValue().toString());
radioGroup.addView(radioButton);
}
}
if (masterkey.substring(0,2).equalsIgnoreCase("CS")) {
if (radioGroup.getCheckedRadioButtonId() == -1) {
Toast.makeText(getBaseContext(), "Please select an option", Toast.LENGTH_SHORT).show();
break;
}
int selectedID = radioGroup.getCheckedRadioButtonId();
RadioButton selectedRadio = (RadioButton) findViewById(selectedID);
keyTag = selectedRadio.getTag().toString();
backList.add(masterkey);
masterkey = keyTag;
createScreen(masterkey);
break;
}
Мои проблемы - это выбранный индекс или результаты;
radioGroup.getCheckedRadioButtonId()
не списываться, даже если я удалить точку. Таким образом, keyTag = selectedRadio.getTag().toString();
предоставляет исключение nullPointerException.
Пожалуйста, дайте мне знать, как сбросить выбранный индекс радиогруппы.
Заранее благодарна