0

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.

Sunil
  • 521
  • 1
  • 7
  • 24
  • How are you handling cancel button? Show it's code – Apurva Mar 14 '15 at 09:15
  • @Apurva i am not using any implementation in alert dilaog cancel . I just cancel the dialog. I want to implement moving the radiobutton selection to the previous one. – Sunil Mar 15 '15 at 08:39

0 Answers0