Drag the icon on the panel to the interface. Then change the Properties, such,
The activity_main.xml list is as follows:
<RadioGroup
Android: id = "@ + id/radioGroup01"
Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content">
<RadioButton
Android: id = "@ + id/radioBtn1"
Android: text = "@ string/sex1"
Android: textSize = "@ dimen/font_size24"
Android: textStyle = "bold"/>
<RadioButton
Android: id = "@ + id/radioBtn2"
Android: text = "@ string/sex2"
Android: textSize = "@ dimen/font_size24"
Android: textStyle = "bold"/>
</RadioGroup>
Then, we start encoding.
The related code is as follows:
RadioGroup radioGrou1 = (RadioGroup) findViewById (R. id. radioGroup01 );
RadioBtn1 = (RadioButton) findViewById (R. id. radioBtn1 );
RadioBtn2 = (RadioButton) findViewById (R. id. radioBtn2 );
RadioGrou1.setOnCheckedChangeListener (this );
The effect is as follows: