用android studio 实现上图的内容,首先是设计界面,线性布局用LinearLayout,布局中有android:orientation属性控制排列方向,horizontal为水平,vertical为垂直方向;第一题为单选题,用RadioGroup和RadioButton结合使用,第二题为多选题,使用CheckBox按钮;两个普通Button按钮;三个文本框,第一第二个显示问题,第三个显示结果。
.xml布局代码为
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/tex1"
android:text="球王“贝利”是哪个国家的人:"
/>
<RadioGroup
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/rg">
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/b11"
android:text="巴西"/>
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/b12"
android:text="德国"/>
<RadioButton
android:layout_width="wrap_content"
android:layout_height="w