Single box and multi box is usually used in setting up user profile, choose gender, hobbies, etc., do not need the user directly input, choose directly in the alternative options, simple and convenient.
Look directly at the code:
<?XML version= "1.0" encoding= "Utf-8"?><Tablelayoutxmlns:android= "Http://schemas.android.com/apk/res/android"android:orientation= "vertical"Android:layout_width= "Match_parent"Android:layout_height= "Match_parent" > <TableRow> <TextViewAndroid:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"Android:text= "Gender"android:textsize= "16pt" /> <!--define a group of radio buttons - <Radiogroupandroid:orientation= "Horizontal"android:layout_gravity= "Center_horizontal" > <RadioButtonAndroid:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"Android:text= "Male"android:textsize= "16pt"android:checked= "true"/> <RadioButtonAndroid:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"Android:text= "female"android:textsize= "16pt"/> </Radiogroup> </TableRow> <TableRow> <TextViewAndroid:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"Android:text= "Hobby"android:textsize= "16pt" /> <!--define a vertical linear layout - <LinearLayoutandroid:layout_gravity= "Center_horizontal"android:orientation= "vertical"Android:layout_width= "Wrap_content"Android:layout_height= "Wrap_content" > <!--define three check boxes - <CheckBoxAndroid:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"Android:text= "singing"android:textsize= "16pt"android:checked= "true"/> <CheckBoxAndroid:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"android:textsize= "16pt"Android:text= "reading"/> <CheckBoxAndroid:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"android:textsize= "16pt"Android:text= "Shopping"/> </LinearLayout> </TableRow></Tablelayout>
Operation Result:
Android Notes (15) basic components in Android--Radio box and check box