mercredi 13 juillet 2016

Logic Failed around RadioGroup Visibility

I have written a small logic around Visibility of RadioGroup, but it fails when I tried it:

if ("some condition") {
     showAlert("Some Message");
} else if ("some condition") {
     showAlert("Some Message");
} else if(radioGroup.getVisibility() == View.VISIBLE) {

     if (radioGroup.getCheckedRadioButtonId() == -1) {

         Toast.makeText(getApplicationContext(), "Please make a selection", Toast.LENGTH_SHORT).show();
         return;
     }

 } else {

   saveData();
   finish();

}

What I have tried above,

I just want to show Toast if Radio Group is Visible and none of the radio button is selected, but I am getting Toast even RadioGroup is not visible WHY ?

Aucun commentaire:

Enregistrer un commentaire