super.onCreate(savedInstanceState);
setContentView(R.layout.radio_group_1);
mRadioGroup = (RadioGroup) findViewById(R.id.menu);
// test adding a radio button programmatically
RadioButton newRadioButton = new RadioButton(this);
newRadioButton.setText(R.string.radio_group_snack);
newRadioButton.setId(R.id.snack);
LinearLayout.LayoutParams layoutParams = new RadioGroup.LayoutParams(
RadioGroup.LayoutParams.WRAP_CONTENT,
RadioGroup.LayoutParams.WRAP_CONTENT);
mRadioGroup.addView(newRadioButton, 0, layoutParams);
// test listening to checked change events
String selection = getString(R.string.radio_group_selection);
mRadioGroup.setOnCheckedChangeListener(this);
mChoice = (TextView) findViewById(R.id.choice);
mChoice.setText(selection + mRadioGroup.getCheckedRadioButtonId());
// test clearing the selection
Button clearButton = (Button) findViewById(R.id.clear);
clearButton.setOnClickListener(this);