单选:Radio Button
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="你的性别为"/> <RadioGroup android:layout_width="fill_parent" android:layout_height="wrap_content" > <RadioButton android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="男"/> <RadioButton android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="女"/> </RadioGroup> </LinearLayout>
多选:Check Box
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="请选择一个你喜欢的动物" /> <CheckBox android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="小猫"/> <CheckBox android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="小狗" /> <CheckBox android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="小猪"/> </LinearLayout>