I am working on an application where my activity has 2 radio buttons.
4 channel
9 channel
Now:
default selection of the screen is on 4channel radio button.
if the user wants to click the (9channel) button, it will open a dialog box prompting user
" if you move, all saved items will be deleted "
- In the dialog box i have "Yes" and "No" button. If you click "Yes" button it will select the 9 channel radio button.
The issues that i want to fix are :
when the user clicks on "No" button on the dialog box, i quit the dialog. But selection of radio button still moves to the (9channel) radio button. How to keep the old selection if user click "No" on the dialog box?
Default selection on the activity is on (4channel) radio button. If the user clicks on the same selected button, i dont want the dialog box to open. The dialog box should open only if i click on the other radio button .
How can i achieve the above 2 scenarios? I don't know how to get the radionbutton view and show to user.
my Code :
rg = (RadioGroup) findViewById(R.id.radioGroup1);
public void addListenerOnButton()
{
OnClickListener listener = new OnClickListener() {
@Override
public void onClick(View v) {
RadioButton rb = (RadioButton) v;
selection = (String) rb.getText();
mFlag = true;
showDialog(SELECTION_ALERT_ID);
}
};
RadioButton rb1 = (RadioButton) findViewById(R.id.radioButton1);
rb1.setOnClickListener(listener);
RadioButton rb2 = (RadioButton) findViewById(R.id.radioButton2);
rb2.setOnClickListener(listener);
}