【Android开发】考试系统

【Android开发】考试系统


一、开发环境需求

在这里插入图片描述

二、系统功能设计

在这里插入图片描述

三、运行结果

1. 欢迎界面

在这里插入图片描述

2. 主界面

在这里插入图片描述

3. 答题界面

在这里插入图片描述

四、主要代码

1. WelcomeActivity.java

代码如下:

package com.ssyw.exam2;


import com.ssyw.exam2.controller.WelcomeController;

import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.annotation.SuppressLint;

import android.content.Intent;
import android.view.WindowManager;
import android.widget.ImageView;


public class WelcomeActivity extends BaseActivity {
	//打开数据库
	private WelcomeController wc=new WelcomeController();
	private Handler mHandler = new Handler();  //创建handler对象
	private ImageView iv_welcome;              //创建视图对象
	
	private int alpha = 255;                   //透明度
	private int b = 0;                         //跳转标记
	@SuppressLint("HandlerLeak")
	@SuppressWarnings("deprecation")
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		//全屏显示
		getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
		setContentView(R.layout.activity_welcome);
		
		wc.init(this);
		//绑定图像视图
		iv_welcome=(ImageView) findViewById(R.id.iv_welcome);
		//设置透明度
		iv_welcome.setAlpha(alpha);
		//创建线程并启动
		new Thread(new Runnable() {
			public void run() {
				//初次进入标记点为0
				while (b < 2) {
					try {
						if (b == 0) {
							Thread.sleep(500);
							b =1;
						} else {
							Thread.sleep(100);
						}
						//更新视图
						updateApp();

					} catch (InterruptedException e) {
						e.printStackTrace();
					}
				}

			}
		}).start();
		//接收handler消息
		mHandler = new Handler() {
			@Override
			public void handleMessage(Message msg) {
				super.handleMessage(msg);
				iv_welcome.setAlpha(alpha); //设置透明度
				iv_welcome.invalidate();    //界面刷新
			}
		};

	}
	public void updateApp() {
		alpha -= 11;
		//避免出现白屏
		if (alpha <= 30) {
			b = 2;//当透明度小于30时 跳转到住页面
			Intent intent = new Intent(WelcomeActivity.this,MainTabActivity.class);
			startActivity(intent);
			this.finish();//关闭欢迎界面
			//查询需要很多内存开销,提前回收一些
			System.gc(); 
		}//发送handler消息
		mHandler.sendMessage(mHandler.obtainMessage());
	}
}

2. activity_classics.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" >
    <!--经典例题页面布局-->
    <include
        android:id="@+id/layout_title_style_1"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        layout="@layout/layout_title_style_1" />
    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="9" >
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical" >
            <TextView
                android:id="@+id/tv_classics_question"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />
            <TextView
                android:id="@+id/tv_classics_answer"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />
        </LinearLayout>
    </ScrollView>
    <Button
        android:id="@+id/btn_classics_show_answer"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:background="@drawable/bg_tab"
        android:onClick="showAnswer"
        android:text="@string/classics_show_answer" />
</LinearLayout>

以上是主要代码,完整文件可点击链接下载

https://download.youkuaiyun.com/download/qq_45647961/19662849

评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Y1wang

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值