These two controls provide a good experience for users to make choices: for example, if users do not need to input them in person, we will provide users with more convenient options. The single-choice button (RadioButton) means that you can select only one option in this option. As the name suggests, the check box control can select multiple options. The following describes the two controls. 5.2.1 example: Example 1: Use of the RadioButton control (the layout file method is used for demonstration here. The usage of RadioButton is described first): <? Xml version = "1.0" encoding = "UTF-8"?> <LinearLayout xmlns: android = "http://schemas.android.com/apk/res/android" android: layout_width = "fill_parent" android: layout_height = "fill_parent" android: orientation = "vertical"> <! -- A set of RadioButton is defined and divided into three options --> <RadioButton android: id = "@ + id/first_radiobutton" android: checked = "true" android: layout_width = "fill_parent" android: layout_height = "wrap_content" android: onClick = "onAction" android: text = "male"/> <RadioButton android: id = "@ + id/second_radiobutton" android: layout_width = "fill_parent" android: layout_height = "wrap_content" android: onClick = "onAction" android: text = "female"/> <RadioB Utton android: id = "@ + id/third_radiobutton" android: layout_width = "fill_parent" android: layout_height = "wrap_content" android: onClick = "onAction" android: text = ""/> </LinearLayout> the above shows the layout file code. Here, we mainly implement the layout interface in Figure 5.1, the code that really wants to implement the function is not here. In the above Code, android: checked = "true"; is used to set the selected option by default, while android: onClick = "onAction" is used to set the listener event method, in java code. Here, you can use RadioGroup to define a set of buttons, that is, in this group, the options are useful. Java code is used here. The Code is as follows: package xbb. bzq. android. app; import android. app. activity; import android. OS. bundle; import android. view. view; import android. widget. radioButton; public class extends Activity {// defines three RadioButton variables: private RadioButton mButton1, mButton2, mButton3; @ Override public void onCreate (Bundle savedInstanceState) {super. onCreate (savedInstanceState); setContentView (R. layout. main); // instantiate three single-choice button controls mButton1 = (RadioButton) findViewById (R. id. first_radiobutton); mButton2 = (RadioButton) findViewById (R. id. second_radiobutton); mButton3 = (RadioButton) findViewById (R. id. third_radiobutton);}/*** this is the listener Method for implementation. It mainly implements the value of the modify option * @ param v */public void onAction (View v) {// determine the user's selection by obtaining the id, and then change the control's selection status switch (v. getId () {case R. id. first_radiobutton: mButton2.setChecked (false); mButton3.setChecked (false); mButton1.setChecked (true); break; case R. id. second_radiobutton: mButton1.setChecked (false); mButton3.setChecked (false); mButton2.setChecked (true); break; case R. id. third_radiobutton: mButton2.setChecked (false); mButton1.setChecked (false); mButton3.setChecked (true); break ;}}}