1. 在学习了郭神的第一行代码前半段之后,想通过一次实践来完成对已学知识的巩固。于是码下了这个图书管理系统客户端。
  1. IDE Android studio,语言 JAVAXML
  1. 在刚开始设计的时候对于这个程序的设定是:
  1. 1.支持学生、教师、工作人员三种不同身份的客户。
  1. 2.学生、老师各自注册账号,并用账号登录。
  1. 3.学生、老师能够查询、借阅、归还图书,逾期没有归还图书的客户将被列入黑名单。
  1. 4.含有图书馆的介绍与新闻通知板块。
  1. 5.管理人员能够添加书籍。
  1. 6.含有新书上架和借阅排行榜两个list
  1. 7.所有信息从服务器上访问得到,支持不同客户端共享相同数据
  1. 在经过了一段时间的磨蹭之后,终于将图书管理系统基本完成:
  1. 但和最开始的设定有了一些偏差:由于教师和学生的不同之处仅仅是借阅书籍的最大数量不同,因此将教师这一身份舍去。在写客户端向服务器(Windows下建了一个微型服务器)通信的时候遇到了很大的困难,长时间的码代码、编译、通过、服务器无反应之后,暂时放弃了连接服务器这一功能,将所有用户与书籍的数据储存在了Android系统自带的数据库中。这样使得过程难度降低了很多,但是无法实现不同客户端访问的数据统一化,也就是从联网退化至了单机。
  1. 但是学习仍在路上,以后有时间当将这些不足得以改善。
  1.  
  1. 下面来讲解图书管理系统的制作过程。
  1. 主页面:
  1.  
  1. 新手上路,界面很low》》》》》》
  1. 1 <?xml version="1.0" encoding="utf-8"?>
  2. 2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3. 3 xmlns:app="http://schemas.android.com/apk/res-auto"
  4. 4 xmlns:tools="http://schemas.android.com/tools"
  5. 5 android:layout_width="match_parent"
  6. 6 android:layout_height="match_parent"
  7. 7 android:gravity="center"
  8. 8 android:orientation="vertical"
  9. 9 tools:context=".MainActivity">
  10. 10
  11. 11 <ImageView
  12. 12 android:id="@+id/image_view_id"
  13. 13 android:layout_width="match_parent"
  14. 14 android:layout_height="0dp"
  15. 15 android:layout_weight="6"
  16. 16 android:src="@drawable/img_1" />
  17. 17
  18. 18 <TextView
  19. 19 android:layout_width="match_parent"
  20. 20 android:layout_height="0dp"
  21. 21 android:gravity="center"
  22. 22 android:textSize="30sp"
  23. 23 android:layout_weight="2"
  24. 24 android:text="欢迎使用图书馆安卓客户端" />
  25. 25
  26. 26 <LinearLayout
  27. 27 android:layout_width="match_parent"
  28. 28 android:layout_height="0dp"
  29. 29 android:layout_weight="4"
  30. 30 android:orientation="horizontal">
  31. 31
  32. 32 <Button
  33. 33 android:id="@+id/introduce_id"
  34. 34 android:layout_width="0dp"
  35. 35 android:layout_height="match_parent"
  36. 36 android:layout_weight="1"
  37. 37 android:textSize="21sp"
  38. 38 android:text="图书馆介绍" />
  39. 39
  40. 40 <Button
  41. 41 android:id="@+id/news_id"
  42. 42 android:layout_width="0dp"
  43. 43 android:layout_height="match_parent"
  44. 44 android:layout_weight="1"
  45. 45 android:textSize="21sp"
  46. 46 android:text="图书馆新闻通知" />
  47. 47 </LinearLayout>
  48. 48
  49. 49 <LinearLayout
  50. 50 android:layout_width="match_parent"
  51. 51 android:layout_height="0dp"
  52. 52 android:layout_weight="4"
  53. 53 android:orientation="horizontal">
  54. 54
  55. 55 <Button
  56. 56 android:id="@+id/newBook_id"
  57. 57 android:layout_width="0dp"
  58. 58 android:layout_height="match_parent"
  59. 59 android:layout_weight="1"
  60. 60 android:textSize="21sp"
  61. 61 android:text="新书上架" />
  62. 62
  63. 63 <Button
  64. 64 android:id="@+id/ranking_id"
  65. 65 android:layout_width="0dp"
  66. 66 android:layout_height="match_parent"
  67. 67 android:layout_weight="1"
  68. 68 android:textSize="21sp"
  69. 69 android:text="借阅排行榜" />
  70. 70 </LinearLayout>
  71. 71
  72. 72 <LinearLayout
  73. 73 android:layout_width="match_parent"
  74. 74 android:layout_height="0dp"
  75. 75 android:layout_weight="4">
  76. 76
  77. 77 <Button
  78. 78 android:id="@+id/registerStudent_id"
  79. 79 android:layout_width="0dp"
  80. 80 android:layout_height="match_parent"
  81. 81 android:layout_weight="1"
  82. 82 android:textSize="21sp"
  83. 83 android:text="学生注册" />
  84. 84 <Button
  85. 85 android:id="@+id/blacklist_id"
  86. 86 android:layout_width="0dp"
  87. 87 android:layout_height="match_parent"
  88. 88 android:layout_weight="1"
  89. 89 android:textSize="21sp"
  90. 90 android:text="黑名单" />
  91. 91 </LinearLayout>
  92. 92 </LinearLayout>

activity_main

下面是主程序的代码:

  1. 1 package com.example.administrator.library1;
  2. 2
  3. 3 import android.content.Intent;
  4. 4 import android.support.v7.app.AppCompatActivity;
  5. 5 import android.os.Bundle;
  6. 6 import android.view.Menu;
  7. 7 import android.view.MenuItem;
  8. 8 import android.view.View;
  9. 9 import android.widget.Button;
  10. 10 import android.widget.Toast;
  11. 11
  12. 12 import org.litepal.LitePal;
  13. 13 /*------
  14. 14 郭志---18年暑假
  15. 15 */
  16. 16
  17. 17 public class MainActivity extends AppCompatActivity {
  18. 18
  19. 19 private Button button_introduce,button_information,button_ranking,button_newBooks,button_register_student,button_blacklist;
  20. 20 @Override
  21. 21 public boolean onCreateOptionsMenu(Menu menu) {
  22. 22 getMenuInflater().inflate(R.menu.main,menu);
  23. 23 return true;
  24. 24 }
  25. 25
  26. 26 @Override
  27. 27 public boolean onOptionsItemSelected(MenuItem item) {
  28. 28 switch (item.getItemId())
  29. 29 {
  30. 30 case R.id.student_id:
  31. 31 Intent intent_student=new Intent(MainActivity.this,Login_student.class);
  32. 32 startActivity(intent_student);
  33. 33 break;
  34. 34 /*case R.id.teacher_id:
  35. 35 Intent intent_teacher=new Intent(MainActivity.this,Login_teacher.class);
  36. 36 startActivity(intent_teacher);
  37. 37 break;*/
  38. 38 case R.id.staff_id:
  39. 39 Intent intent_staff=new Intent(MainActivity.this,Login_staff.class);
  40. 40 startActivity(intent_staff);
  41. 41 break;
  42. 42 }
  43. 43 return true;
  44. 44 }
  45. 45
  46. 46 @Override
  47. 47 protected void onCreate(Bundle savedInstanceState) {
  48. 48 super.onCreate(savedInstanceState);
  49. 49 setContentView(R.layout.activity_main);
  50. 50 button_introduce=findViewById(R.id.introduce_id);
  51. 51 button_register_student=findViewById(R.id.registerStudent_id);
  52. 52 button_blacklist=findViewById(R.id.blacklist_id);
  53. 53 button_information=findViewById(R.id.news_id);
  54. 54 button_ranking=findViewById(R.id.ranking_id);
  55. 55 button_newBooks=findViewById(R.id.newBook_id);
  56. 56
  57. 57 button_introduce.setOnClickListener(new View.OnClickListener() {
  58. 58 @Override
  59. 59 public void onClick(View view) {
  60. 60 Intent intent=new Intent(MainActivity.this,Introduction.class);
  61. 61 startActivity(intent);
  62. 62 finish();
  63. 63 }
  64. 64 });
  65. 65 button_register_student.setOnClickListener(new View.OnClickListener() {
  66. 66 @Override
  67. 67 public void onClick(View view) {
  68. 68 Intent intent=new Intent(MainActivity.this,Register_student.class);
  69. 69 startActivity(intent);
  70. 70 finish();
  71. 71 }
  72. 72 });
  73. 73 button_blacklist.setOnClickListener(new View.OnClickListener() {
  74. 74 @Override
  75. 75 public void onClick(View view) {
  76. 76 Intent intent=new Intent(MainActivity.this,Blacklist.class);
  77. 77 startActivity(intent);
  78. 78 finish();
  79. 79 }
  80. 80 });
  81. 81 button_information.setOnClickListener(new View.OnClickListener() {
  82. 82 @Override
  83. 83 public void onClick(View view) {
  84. 84 Intent intent=new Intent(MainActivity.this,News.class);
  85. 85 startActivity(intent);
  86. 86 finish();
  87. 87 }
  88. 88 });
  89. 89 button_ranking.setOnClickListener(new View.OnClickListener() {
  90. 90 @Override
  91. 91 public void onClick(View view) {
  92. 92 Intent intent=new Intent(MainActivity.this,Ranking.class);
  93. 93 startActivity(intent);
  94. 94 finish();
  95. 95 }
  96. 96 });
  97. 97 button_newBooks.setOnClickListener(new View.OnClickListener() {
  98. 98 @Override
  99. 99 public void onClick(View view) {
  100. 100 Intent intent=new Intent(MainActivity.this,New_Books.class);
  101. 101 startActivity(intent);
  102. 102 finish();
  103. 103 }
  104. 104 });
  105. 105
  106. 106 }
  107. 107 }

MainActivity.java

当然我们的程序都得先在注册表中进行注册,一些权限的开启也在注册表中。
  1. 1 <?xml version="1.0" encoding="utf-8"?>
  2. 2 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
  3. 3 package="com.example.administrator.library1">
  4. 4
  5. 5 <uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
  6. 6 <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
  7. 7 <uses-permission android:name="android.permission.INTERNET" />
  8. 8
  9. 9 <application
  10. 10 android:name="org.litepal.LitePalApplication"
  11. 11 android:allowBackup="true"
  12. 12 android:icon="@mipmap/ic_launcher"
  13. 13 android:label="图书馆"
  14. 14 android:roundIcon="@mipmap/ic_launcher_round"
  15. 15 android:supportsRtl="true"
  16. 16 android:theme="@style/AppTheme">
  17. 17 <activity android:name=".MainActivity">
  18. 18 <intent-filter>
  19. 19 <action android:name="android.intent.action.MAIN" />
  20. 20
  21. 21 <category android:name="android.intent.category.LAUNCHER" />
  22. 22 </intent-filter>
  23. 23 </activity>
  24. 24 <activity android:name=".Login_student" />
  25. 25 <activity android:name=".Login_teacher" />
  26. 26 <activity android:name=".Login_staff" />
  27. 27 <activity android:name=".Register_student" />
  28. 28 <activity android:name=".Register_teacher" />
  29. 29 <activity android:name=".Introduction" />
  30. 30 <activity android:name=".Student_homepage" />
  31. 31 <activity android:name=".Teacher_homepage" />
  32. 32 <activity android:name=".Staff_homepage" />
  33. 33 <activity android:name=".News" />
  34. 34 <activity android:name=".staff_input" />
  35. 35 <activity android:name=".Ranking" />
  36. 36 <activity android:name=".New_Books" />
  37. 37 <activity android:name=".Blacklist"></activity>
  38. 38 </application>
  39. 39
  40. 40 </manifest>

manifest

整个项目中用到了Github上面的许多开源项目,如Litepal,OKhttp,这些都在build grade中引用过,代码贴出:

  1. 1 apply plugin: 'com.android.application'
  2. 2
  3. 3 android {
  4. 4 compileSdkVersion 26
  5. 5 defaultConfig {
  6. 6 applicationId "com.example.administrator.library1"
  7. 7 minSdkVersion 15
  8. 8 targetSdkVersion 26
  9. 9 versionCode 1
  10. 10 versionName "1.0"
  11. 11 testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
  12. 12 }
  13. 13 buildTypes {
  14. 14 release {
  15. 15 minifyEnabled false
  16. 16 proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
  17. 17 }
  18. 18 }
  19. 19 }
  20. 20
  21. 21 dependencies {
  22. 22 implementation fileTree(dir: 'libs', include: ['*.jar'])
  23. 23 implementation 'com.android.support:appcompat-v7:26.1.0'
  24. 24 implementation 'com.android.support.constraint:constraint-layout:1.1.2'
  25. 25 testImplementation 'junit:junit:4.12'
  26. 26 implementation 'com.squareup.okhttp3:okhttp:3.11.0'
  27. 27 implementation 'com.android.support:recyclerview-v7:26.1.0'
  28. 28 implementation 'org.litepal.android:core:2.0.0'
  29. 29 androidTestImplementation 'com.android.support.test:runner:1.0.2'
  30. 30 androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
  31. 31 }

build gradle

整个管理系统无论是哪个用户,哪一个功能都离不开数据,这些数据都存储在本地的数据库里。关于数据库的设计是这样的:

  1. 1 <?xml version="1.0" encoding="utf-8"?>
  2. 2 <litepal>
  3. 3 <dbname value="library"></dbname>
  4. 4 <version value="10"></version>
  5. 5 <list>
  6. 6 <mapping class="com.example.administrator.library1.Student"></mapping>
  7. 7 <mapping class="com.example.administrator.library1.Teacher"></mapping>
  8. 8 <mapping class="com.example.administrator.library1.Book"></mapping>
  9. 9 <mapping class="com.example.administrator.library1.Staff"></mapping>
  10. 10 <mapping class="com.example.administrator.library1.Simple"></mapping>
  11. 11 </list>
  12. 12 </litepal>

library库由五个表构成:学生、教师(停用)、书籍、职员、简单信息(用于存储记住密码之后的账号、密码信息)组成。

下一篇,我将来讲述学生的注册、登录、借还书功能的实现。

(先附上整个项目的源码地址:https://github.com/Guozhi-explore/androidlibrary)

基于Android平台的图书管理系统的制作(1)的更多相关文章

  1. 基于Android平台的图书管理系统的制作(2)

    上一篇讲解了制作图书管理系统的初衷与要求,和app首页的代码. 下面来介绍图书管理系统的服务对象:学生 学生类的设计: 个人信息:账号.密码.姓名.学号.邮箱.年龄. 借阅信息:借阅总数(不超过十本) ...

  2. 基于Android平台的图书管理系统的制作(3)

    前两篇介绍了主页面和Student,这一篇来讲Book类和工作人员. Book是图书管理系统的核心,查书,借书,还书,增加书都与Book类息息相关.Book类的设计很简单:包含信息:名称.作者.页数. ...

  3. 基于Android平台的图书管理系统的制作(4)

    讲解完学生.职员.书籍这些基础层之后,我们可以来了解一些应用层的活动. 新书上架.借阅排行.黑名单.图书馆介绍.图书馆新闻. 新书上架是查询数据库里的Book表,将最近注册的五本书的基本信息(若图书馆 ...

  4. 基于Android平台的会议室管理系统具体设计说明书

    会议室管理系统具体设计说明书 第一部分  引言 1.编写目的 本说明对会议室管理系统项目的各模块.页面.脚本分别进行了实现层面上的要求和说明. 软件开发小组的产品实现成员应该阅读和參考本说明进行代码的 ...

  5. 基于android平台的斗地主AI

    本软件是基于android平台的斗地主AI,我们在源代码的基础之上,旨在改进AI的算法,使玩家具有更丰富的体验感,让NPC可以更为智能. (一)玩法解析: (1)发牌和叫牌:一副扑克54张,先为每个人 ...

  6. 基于Android 平台简易即时通讯的研究与设计[转]

    摘要:论文简单介绍Android 平台的特性,主要阐述了基于Android 平台简易即时通讯(IM)的作用和功能以及实现方法.(复杂的通讯如引入视频音频等可以考虑AnyChat SDK~)关键词:An ...

  7. 基于Android平台的简易人脸检测库

    代码地址如下:http://www.demodashi.com/demo/12135.html ViseFace 简易人脸检测库,不依赖三方库,可快速接入人脸检测功能. 项目依赖:compile 'c ...

  8. 基于ANDROID平台,U3D对蓝牙手柄键值的获取

    对于ANDROID平台,物理蓝牙手柄已被封装,上层应用不可见,也就是说对于上层应用,不区分蓝牙手柄还是其它手柄: 完成蓝牙手柄和ANDROID手机的蓝牙连接后,即可以UNITY3D中获取其键值: 在U ...

  9. 结对编程--基于android平台的黄金点游戏

    游戏内容: 阿超的课都是下午两点钟,这时班上不少的同学都昏昏欲睡,为了让大家兴奋起来,阿超让同学玩一个叫“黄金点”的游戏: N个同学(N通常大于10),每人写一个0~100之间的有理数 (不包括0或1 ...

随机推荐

  1. Win64 驱动内核编程-22.SHADOW SSDT HOOK(宋孖健)

    SHADOW SSDT HOOK HOOK 和 UNHOOK SHADOW SSDT 跟之前的 HOOK/UNHOOK SSDT 类似,区别是查找SSSDT的特征码,以及根据索引计算函数地址的公式,还 ...

  2. android 资料

    https://xfans.gitbooks.io/android-book/content/issue-39/Android%20dex%E5%88%86%E5%8C%85%E5%AF%BC%E8% ...

  3. RSS阅读器 - Reeder

    苹果生态圈内最佳RSS阅读器 - Reeder 好用就完事了

  4. 基于蒙特卡洛树搜索(MCTS)的多维可加性指标的异常根因定位

    摘要:本文是我在从事AIOps研发工作中做的基于MCTS的多维可加性指标的异常根因定位方案,方案基于清华大学AIOPs实验室提出的Hotspot算法,在此基础上做了适当的修改. 1        概述 ...

  5. 『政善治』Postman工具 — 9、在Postman中使用断言

    目录 1.Tests的介绍 2.常用SNIPPETS(片段)说明 (1)常用变量相关 (2)状态码相关 (3)响应结果断言: (4)Header : (5)响应速度: 3.示例 (1)响应码断言 (2 ...

  6. [刷题] 1022 D进制的A+B (20分)

    思路 设t = A + B,将每一次t % d的结果保存在int类型的数组s中 然后将t / d,直到 t 等于 0为止 此时s中保存的就是 t 在 D 进制下每一位的结果的倒序 最后倒序输出s数组 ...

  7. 【转载】windows linux cent 7 制作U盘 启动盘

    1 镜像iso文件存放在linux环境下用dd if=/dev/sdb of=/镜像存放路径/镜像iso文件 bs=1M u盘的盘符是/dev/sdb 2 镜像iso文件存放在windows环境下ul ...

  8. 【转载】CentOS 7 系统区域(语言)和键盘设置

    CentOS 7 系统区域(语言)和键盘设置   即使是在window中,平常说的语言设置这一项也是归类为系统区域,CentOS可以通过修改/etc/locale.conf配置文件或使用localec ...

  9. Linux_源码安装包管理理论概述

    一.源码包基本概述 1️⃣:源码包的编译用到了linux系统里的编译器,通常源码包都是用C语言开发的,这也是因为C语言为linux上最标准的程序语言 2️⃣:Linux上的C语言编译器叫做gcc,利用 ...

  10. 056.Python前端Django模型ORM多表基本操作

    一 准备工作 1.1 新建一个项目 root@darren-virtual-machine:~# cd /root/PycharmProjects/ root@darren-virtual-machi ...