学了单选按钮所以自己尝试着写了一个选择题答卷并进行简单打分,其页面效果如下:

为了防止更改答案提交,可以让按钮只执行一次,进行单选后点击提交后如图:

功能比较简单,其资源文件中Layout下XML实现代码为:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"
android:layout_width="match_parent">
<LinearLayout
android:id="@+id/activity_homepage"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="小学教师证考试题"
android:textSize="30sp"
android:layout_gravity="center"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="一,单项选择题"
android:textSize="25sp"
/>
<TextView
android:id="@+id/select1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1,教育史上最早的教学手段是"
android:textSize="20sp"

本文展示了作者在学习安卓开发时,如何使用单选按钮创建选择题答题页面并实现简单的评分功能。页面包含一个可滚动的ScrollView以容纳超出屏幕的内容。Java活动页面逻辑代码用于处理用户交互,目前功能较为基础,作者期待优化建议。
最低0.47元/天 解锁文章
392





