如何在单行中创建多个单选按钮,至少4个问题?

时间:2017-11-25 21:00:19

标签: android

如何在单行中创建多个单选按钮,至少4个问题,并以是或否的形式回答,最后它必须计算多少是和多少没有

像:

  1. 你去办公室是/否
  2. 你是乘坐公共汽车/出租车
  3. 您是否有兴趣参加研讨会是/否
  4. 最后,必须使用按钮

    计算结果

1 个答案:

答案 0 :(得分:0)

使用

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">
    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Are you going to school "/>
    <RadioGroup
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">
        <RadioButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Yes"/>
        <RadioButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="No"/>
    </RadioGroup>
</LinearLayout>

这就是你的一个问题。像这样做另外三个问题,并将radiobutton的状态存储在一个数组中。最后,计算并显示。