1

genderOption.setOnCheckedChangeListener(
//anonymous class
    new RadioGroup.OnCheckedChangeListener() {

    @Override
    public void onCheckedChanged(RadioGroup radioGroup, int checkedId) {
//referencing an object to retrieve Id
        RadioButton rb = (RadioButton)radioGroup.findViewById(checkedId);
        switch (rb.getId()){
              case R.id.rbMale:
                  maleGender.setText("Boy");
                  break;
              case R.id.rbFemale:
                  femaleGender.setText("Girl");
                  break;
          }
//end of switch
    }
    });
/*End of listening to clicks on radio buttons*/
|