使用ListView和RadioGroup做单选题,并且将所选选项保存起来

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="
  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值