Skip to content

Instantly share code, notes, and snippets.

@gmsetiawan
Created July 6, 2014 10:25
Show Gist options
  • Select an option

  • Save gmsetiawan/1ecaf7e8bdeb9d7a24ec to your computer and use it in GitHub Desktop.

Select an option

Save gmsetiawan/1ecaf7e8bdeb9d7a24ec to your computer and use it in GitHub Desktop.
// Radio Button Group - Gender
RadioGroup rgGender = (RadioGroup) findViewById(R.id.radioGroup1);
RadioButton rbMale = (RadioButton) findViewById(R.id.radio0);
RadioButton rbFemale = (RadioButton) findViewById(R.id.radio1);
rgGender.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
// TODO Auto-generated method stub
if (checkedId == R.id.radio0) {
Toast.makeText(getApplicationContext(),
"Male isChecked", Toast.LENGTH_SHORT).show();
} else if (checkedId == R.id.radio1) {
Toast.makeText(getApplicationContext(),
"Female isChecked", Toast.LENGTH_SHORT).show();
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment