Single choice button and check box, single choice button check box
Demo2 \ radiocheck_demo \ src \ main \ res \ layout \ activity_main.xml
1 <TableLayout xmlns: android = "http://schemas.android.com/apk/res/android" 2 xmlns: tools = "http://schemas.android.com/tools" 3 android: layout_width = "match_parent" 4 android: layout_height = "match_parent" 5 tools: context = ". mainActivity "6 android: orientation =" vertical "> 7 8 <TableRow> 9 <TextView10 android: layout_width =" wrap_content "11 android: layout_height =" wrap_content "12 android: text = "Gender:" 13 android: TextSize = "20sp"/> 14 <! -- Define a group of radio buttons --> 15 <RadioGroup16 android: orientation = "horizontal" 17 android: layout_gravity = "center_horizontal"> 18 <! -- Define two radio buttons --> 19 <RadioButton20 android: layout_width = "wrap_content" 21 android: layout_height = "wrap_content" 22 android: text = "male"/> 23 <RadioButton24 android: layout_width = "wrap_content" 25 android: layout_height = "wrap_content" 26 android: text = "" 27 android: checked = "true"/> 28 </RadioGroup> 29 </TableRow> 30 31 <TableRow> 32 <TextView33 android: layout_width = "wrap_content" 34 android: layout_height = "wrap_content" 35 Android: text = "Favorite color" 36 android: textSize = "20sp"/> 37 <! -- Define a vertical linear layout --> 38 <LinearLayout39 android: layout_gravity = "center_horizontal" 40 android: orientation = "vertical" 41 android: layout_width = "wrap_content" 42 android: layout_height = "wrap_content"> 43 <! -- Define three check boxes --> 44 <CheckBox45 android: layout_width = "wrap_content" 46 android: layout_height = "wrap_content" 47 android: text = "red" 48 android: checked = "true"/> 49 <CheckBox50 android: layout_width = "wrap_content" 51 android: layout_height = "wrap_content" 52 android: text = "blue"/> 53 <CheckBox54 android: layout_width = "wrap_content" 55 android: layout_height = "wrap_content" 56 android: text = "green"/> 57 </LinearLayout> 58 </TableRow> 59 60 </TableLayout>