1.建立一个QItem类,来实现每道题的构造方法<span style="font-size:18px;"><pre name="code" class="java"><span style="font-size:18px;"> class QItem{
//问题
private String text;
//选项
private String A;
private String B;
private String C;
//正确选项按钮Id
private int answer;
public String getText() {
return text;
}
public String getA() {
return A;
}
public String getB() {
return B;
}
public String getC() {
return C;
}
public int getAnswer() {
return answer;
}
public QItem(String text, String a, String b, String c, int answer) {
super();
this.text = text;
A = a;
B = b;
C = c;
this.answer = answer;
}
public QItem() {
super();
}
}</span></span>
Item的布局方式
<pre name="code" class="html"><span style="font-size:18px;"><?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"
android:id="@+id/exam_layout">
<TextView
android:id="@+id/examquestion_tvId"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="question"
android:textAppearance="?android:attr/textAppearanceMedium" />
<RadioGroup
android:id="@+id/exam_xuanzerp_Id"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<RadioButton
android:id="@+id/exam_A"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="A" />
<RadioButton
android:id="@+id/exam_B"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="B" />
<RadioButton
android:id="@+id/exam_C"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="C" />
</RadioGroup>
</LinearLayout></span>
<h1>Activity</h1><div><pre name="code" class="html"><span style="font-size:18px;"><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ExamActivity" >
<ScrollView
android:id="@+id/exam_scrId"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="