[Solved] Reset a Radio button inside a Radio group


This is how I did it:

It is in C# but I think it is easy to convert it to Java.

I used tag to know if this radio button checked before or not.

False => It is not checked

True => It is checked

radiobutton.Tag = false;

radiobutton.Click += SingleChoiceQuestionAlternativeClick;

Then:

private void SingleChoiceQuestionAlternativeClick(object sender, EventArgs e)
    {
        RadioButton questionAlternative = sender as RadioButton;

        if (questionAlternative != null)
        {
            RadioGroup questionAlternatives = questionAlternative.Parent as RadioGroup;

            if (questionAlternatives != null)
            {
                if (questionAlternative.Tag.Equals(false))
                {
                    for (int i = 0; i < questionAlternatives.ChildCount; i++)
                    {
                        RadioButton childRadioButton = questionAlternatives.GetChildAt(i) as RadioButton;

                        if (childRadioButton != null)
                        {
                            childRadioButton.Tag = false;
                        }
                    }

                    questionAlternative.Tag = true;
                }
                else
                {
                    questionAlternative.Tag = false;
                    questionAlternatives.ClearCheck();
                }
            }
        }
    }

solved Reset a Radio button inside a Radio group