I am using radio button in Android
my code about radio button
public void addListenerOnButton()
{
OnClickListener listener = new OnClickListener() {
@Override
public void onClick(View v) {
RadioButton rb = (RadioButton) v;
selection = (String) rb.getText();
if(customGridAdapter.mThumb9Ids[0].equals("False"))
{
Toast.makeText(LiveFavoriteGridListActivity.this, selection,
Toast.LENGTH_SHORT).show();
}
else
{
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);
}
I am using a dialog box to check some validation during radio button selection. showDialog(SELECTION_ALERT_ID);
Default selection is radiobutton1.
When i select radiobutton 2 , it opens a dialog box to check some validation. when i click OK it moves to the radiobutton2 selection.
When i click cancel , it should remain in radiobutton1 selection.
But, Currently when i click cancel, selection still moves to radio button2.
Please tell me how i can restrict the selection to remain as is, when i click cancel on the dialog box.