Unable to check beacon

why can't I check the same radio object after I remove it programmatically, when I press the next button, if I do not check another radio object.

This is the code that disables the radio buttons:

if(q.trim() != null || q.trim() != ""){ questionView.setText(q); r1.setChecked(false); r2.setChecked(false); r3.setChecked(false); r1.clearFocus(); r2.clearFocus(); r3.clearFocus(); r1.setText(varNames.get("ra0")); r2.setText(varNames.get("ra1")); r3.setText(varNames.get("ra2")); } 

And this is where I am trying to verify this:

 public void questionClicked(View view) { boolean checked = ((RadioButton) view).isChecked(); switch(view.getId()) { case R.id.firstQuestion: if(!checked) { r1.setChecked(true); } getAnswer(R.id.firstQuestion); break; case R.id.secondQuestion: if(!checked) { r2.setChecked(true); } getAnswer(R.id.secondQuestion); break; case R.id.thirdQuestion: if(!checked) { r3.setChecked(true); } getAnswer(R.id.thirdQuestion); break; } } 
+5
source share
1 answer

I think you should do a way to clear the registered switch. And name it every time you click the "Next" button. Here is an example:

 private void clearcheck(){ if(q.trim() != null || q.trim() != ""){ questionView.setText(q); r1.setChecked(false); r2.setChecked(false); r3.setChecked(false); r1.clearFocus(); r2.clearFocus(); r3.clearFocus(); r1.setText(varNames.get("ra0")); r2.setText(varNames.get("ra1")); r3.setText(varNames.get("ra2")); } } 

Name it as clearcheck (); in onclick your next button.

0
source

Source: https://habr.com/ru/post/1263105/


All Articles