Skip to content Skip to sidebar Skip to footer

Radiobutton Returns False After First Run

Hello everyone and happy new year. I have a problem. After the time a radiobutton.isChecked() is true returns always false. For example, if (rb.isChecked()) //do something This i

Solution 1:

I had the same problem. I bypassed it in this way:

publicclassMainActivityextendsAppCompatActivity 
{
privateboolean check=false;
...
...
...
publicvoidchecked(View arg0)
{
     if(!check)
     check=true;
     else
     check=false;
}
...
...
...
}

Then in the layout in the RadioButton you have to set

android:onClick="checked"

In this way you'll always know if the radiobutton is cheked or not. I simply exploited an instance variable to control condition of the radiobutton.

Post a Comment for "Radiobutton Returns False After First Run"