Android简单学生信息管理系统(LitePal)

附上源码:https://github.com/LiuJingyingdev/StudentSystem

进入正题:

本App用的是LitePal来操作数据库的,比较简单,就是自己学了LitePal后,马上就动手做App了,由于中间遇到了一个非常头疼的事情,就是到一个地方,老是崩溃,弄得我自己都差点放弃了,后来解决了。

主要功能:

  1. 登录,注册
  2. 创建数据库
  3. 学生信息的增删改查(每个学生的信息比较少,就只有学号姓名,其实学会了这个,后面都是造轮子)

首先是界面(就不要吐槽我的界面了,理科生的审美观,真的可怕):

登录界面、主界面

主界面代码:

package com.example.studentsystem;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import org.litepal.LitePal;

public class StudentMenu extends AppCompatActivity implements View.OnClickListener{

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.student_menu);
        Button addStudent = (Button) findViewById(R.id.add_stu);
        Button deleteStudent = (Button) findViewById(R.id.delete_stu);
        Button updateStudent = (Button) findViewById(R.id.update_stu);
        Button queryStudent = (Button) findViewById(R.id.query_stu);
        Button exitSystem = (Button) findViewById(R.id.exit_stu);

        addStudent.setOnClickListener(this);
        deleteStudent.setOnClickListener(this);
        updateStudent.setOnClickListener(this);
        queryStudent.setOnClickListener(this);
        exitSystem.setOnClickListener(this);
    }

    @Override
    public void onClick(View view){
        switch (view.getId()){
            case R.id.add_stu:
                Intent intent1 = new Intent(StudentMenu.this,AddStudent.class);
                startActivity(intent1);
                break;
            case R.id.delete_stu:
                Intent intent2 = new Intent(StudentMenu.this,DeleteStudent.class);
                startActivity(intent2);
                break;
            case R.id.update_stu:
                Intent intent3 = new Intent(StudentMenu.this,UpdateStudent.class);
                startActivity(intent3);
                break;
            case R.id.query_stu:
                Intent intent4 = new Intent(StudentMenu.this,QueryStudent.class);
                startActivity(intent4);
                break;
            case R.id.exit_stu:
                finish();
                break;
            default:
                break;
        }
    }
}

主界面代码:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/piture4">


        <View
            android:layout_width="match_parent"
            android:layout_height="80dp"></View>

        <Button
            android:id="@+id/add_stu"
            android:layout_width="130sp"
            android:layout_height="40sp"
            android:text="增加学生信息"
            android:textColor="#ffffff"
            android:background="@drawable/shape"
            android:layout_gravity="center"/>
        <View
            android:layout_width="12dp"
            android:layout_height="30sp"></View>
        <Button
            android:id="@+id/delete_stu"
            android:layout_width="130sp"
            android:layout_height="40sp"
            android:text="删除学生信息"
            android:textColor="#ffffff"
            android:background="@drawable/shape"
            android:layout_gravity="center"/>
        <View
            android:layout_width="12dp"
            android:layout_height="30sp"></View>
        <Button
            android:id="@+id/update_stu"
            android:layout_width="130sp"
            android:layout_height="40sp"
            android:text="更新学生信息"
            android:textColor="#ffffff"
            android:background="@drawable/shape"
            android:layout_gravity="center"/>
        <View
            android:layout_width="12dp"
            android:layout_height="30sp"></View>
        <Button
            android:id="@+id/query_stu"
            android:layout_width="130sp"
            android:layout_height="40sp"
            android:text="查看学生信息"
            android:textColor="#ffffff"
            android:background="@drawable/shape"
            android:layout_gravity="center"/>




            <View
                android:layout_width="12dp"
                android:layout_height="30sp"></View>

            <Button
                android:id="@+id/exit_stu"
                android:layout_width="130sp"
                android:layout_height="40sp"
                android:layout_alignParentBottom="true"
                android:text="退出学生系统"
                android:textColor="#ffffff"
                android:background="@drawable/shape"
                android:layout_gravity="center"/>

</LinearLayout>

由于有很多个类,我就不全部列出来了,Github已送上,欢迎参考。

  • 0
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值