我正在创建一个android应用程序,并希望将我的活动设置为具有多个答案的问题,他们可以从中进行选择。我在想单选按钮,但我相信有更适合这项任务的东西。示例
Question
Answer1[x]Answer2[x]Answer3[x]
对问题使用TextView
,对以下的答案使用ListView
并进行多选
ListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
如果用户可以选择多个选项,请使用CheckBox
。
RadioButton
用于用户只能选择一个选项的情况。
关于布局:
这真的取决于,有很多可能的解决方案,其中一种可能性是:
<!--not all attributes are included,such as width and height, you have to add them-->
<LinearLayout android:orientation="vertical">
<TextView />
<LinearLayout android:orientation="horizontal"> <!--contains options-->
<CheckBox /> <CheckBox/> <CheckBox />
</LinearLayout>
</LinearLayout>