how can i always set the first radio button as checked in my radio group? Whenever the radio button is selected, it will be set to invisible?(i wanted to remove it but failed) So lets say i got 3 radio button:
and a submit button. If the submit button is clicked, it will remove whatever is selected and set the next first radio button as checked default. My implementation of these radio button will be in a popupwndow.
Lets say when the popup was shown at the very first time, Option 1 will be checked. and lets say i select option 2 and click submit. Upon the next showing of the popupwinddow, it is left only Option 1 and Option 3, the default will still be at Option 1. This time round i select Option 1 and click submit, the next showing of popupwindow will show only Option 3 and default checked as Option 3.
Guys how can i achieve this?
You have maintain the shared preference value for user selection and based on that values you have to show/hide the radio buttons programatically
UPDATE
You can select the first visible radio button in a radio group like below
void selectFirstVisibleRadioButton(RadioGroup radioGroup) {
int childCount = radioGroup.getChildCount();
for (int i = 0; i < childCount; i++) {
RadioButton rButton = (RadioButton) radioGroup.getChildAt(i);
if (rButton.getVisibility() == View.VISIBLE) {
rButton.setChecked(true);
return;
}
}
}