基于Android平台的图书管理系统的制作

【基于Android平台的图书管理系统的制作】会挽雕弓如满月,西北望,射天狼。这篇文章主要讲述基于Android平台的图书管理系统的制作相关的知识,希望能为你提供帮助。
图书馆手机客户端的制作之首页在学习了郭神的第一行代码前半段之后,想通过一次实践来完成对已学知识的巩固。于是码下了这个图书管理系统客户端。 IDE android studio,语言 java、XML; 在刚开始设计的时候对于这个程序的设定是: 1.支持学生、教师、工作人员三种不同身份的客户。 2.学生、老师各自注册账号,并用账号登录。 3.学生、老师能够查询、借阅、归还图书,逾期没有归还图书的客户将被列入黑名单。 4.含有图书馆的介绍与新闻通知板块。 5.管理人员能够添加书籍。 6.含有新书上架和借阅排行榜两个list。 7.所有信息从服务器上访问得到,支持不同客户端共享相同数据 在经过了一段时间的磨蹭之后,终于将图书管理系统基本完成: 但和最开始的设定有了一些偏差:由于教师和学生的不同之处仅仅是借阅书籍的最大数量不同,因此将教师这一身份舍去。在写客户端向服务器(Windows下建了一个微型服务器)通信的时候遇到了很大的困难,长时间的码代码、编译、通过、服务器无反应之后,暂时放弃了连接服务器这一功能,将所有用户与书籍的数据储存在了Android系统自带的数据库中。这样使得过程难度降低了很多,但是无法实现不同客户端访问的数据统一化,也就是从联网退化至了单机。 但是学习仍在路上,以后有时间当将这些不足得以改善。   下面来讲解图书管理系统的制作过程。 主页面:

基于Android平台的图书管理系统的制作

文章图片
基于Android平台的图书管理系统的制作

文章图片
新手上路,界面很low》》》》》》
基于Android平台的图书管理系统的制作

文章图片
基于Android平台的图书管理系统的制作

文章图片
1 < ?xml version="1.0" encoding="utf-8"?> 2 < LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 3xmlns:app="http://schemas.android.com/apk/res-auto" 4xmlns:tools="http://schemas.android.com/tools" 5android:layout_width="match_parent" 6android:layout_height="match_parent" 7android:gravity="center" 8android:orientation="vertical" 9tools:context=".MainActivity"> 10 11< ImageView 12android:id="@+id/image_view_id" 13android:layout_width="match_parent" 14android:layout_height="0dp" 15android:layout_weight="6" 16android:src="https://www.songbingjia.com/android/@drawable/img_1" /> 17 18< TextView 19android:layout_width="match_parent" 20android:layout_height="0dp" 21android:gravity="center" 22android:textSize="30sp" 23android:layout_weight="2" 24android:text="欢迎使用图书馆安卓客户端" /> 25 26< LinearLayout 27android:layout_width="match_parent" 28android:layout_height="0dp" 29android:layout_weight="4" 30android:orientation="horizontal"> 31 32< Button 33android:id="@+id/introduce_id" 34android:layout_width="0dp" 35android:layout_height="match_parent" 36android:layout_weight="1" 37android:textSize="21sp" 38android:text="图书馆介绍" /> 39 40< Button 41android:id="@+id/news_id" 42android:layout_width="0dp" 43android:layout_height="match_parent" 44android:layout_weight="1" 45android:textSize="21sp" 46android:text="图书馆新闻通知" /> 47< /LinearLayout> 48 49< LinearLayout 50android:layout_width="match_parent" 51android:layout_height="0dp" 52android:layout_weight="4" 53android:orientation="horizontal"> 54 55< Button 56android:id="@+id/newBook_id" 57android:layout_width="0dp" 58android:layout_height="match_parent" 59android:layout_weight="1" 60android:textSize="21sp" 61android:text="新书上架" /> 62 63< Button 64android:id="@+id/ranking_id" 65android:layout_width="0dp" 66android:layout_height="match_parent" 67android:layout_weight="1" 68android:textSize="21sp" 69android:text="借阅排行榜" /> 70< /LinearLayout> 71 72< LinearLayout 73android:layout_width="match_parent" 74android:layout_height="0dp" 75android:layout_weight="4"> 76 77< Button 78android:id="@+id/registerStudent_id" 79android:layout_width="0dp" 80android:layout_height="match_parent" 81android:layout_weight="1" 82android:textSize="21sp" 83android:text="学生注册" /> 84< Button 85android:id="@+id/blacklist_id" 86android:layout_width="0dp" 87android:layout_height="match_parent" 88android:layout_weight="1" 89android:textSize="21sp" 90android:text="黑名单" /> 91< /LinearLayout> 92 < /LinearLayout>

activity_main下面是主程序的代码:
基于Android平台的图书管理系统的制作

文章图片
基于Android平台的图书管理系统的制作

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

MainActivity.java 当然我们的程序都得先在注册表中进行注册,一些权限的开启也在注册表中。
基于Android平台的图书管理系统的制作

文章图片
基于Android平台的图书管理系统的制作

文章图片
1 < ?xml version="1.0" encoding="utf-8"?> 2 < manifest xmlns:android="http://schemas.android.com/apk/res/android" 3package="com.example.administrator.library1"> 4 5< uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" /> 6< uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> 7< uses-permission android:name="android.permission.INTERNET" /> 8 9< application 10android:name="org.litepal.LitePalApplication" 11android:allowBackup="true" 12android:icon="@mipmap/ic_launcher" 13android:label="图书馆" 14android:roundIcon="@mipmap/ic_launcher_round" 15android:supportsRtl="true" 16android:theme="@style/AppTheme"> 17< activity android:name=".MainActivity"> 18< intent-filter> 19< action android:name="android.intent.action.MAIN" /> 20 21< category android:name="android.intent.category.LAUNCHER" /> 22< /intent-filter> 23< /activity> 24< activity android:name=".Login_student" /> 25< activity android:name=".Login_teacher" /> 26< activity android:name=".Login_staff" /> 27< activity android:name=".Register_student" /> 28< activity android:name=".Register_teacher" /> 29< activity android:name=".Introduction" /> 30< activity android:name=".Student_homepage" /> 31< activity android:name=".Teacher_homepage" /> 32< activity android:name=".Staff_homepage" /> 33< activity android:name=".News" /> 34< activity android:name=".staff_input" /> 35< activity android:name=".Ranking" /> 36< activity android:name=".New_Books" /> 37< activity android:name=".Blacklist"> < /activity> 38< /application> 39 40 < /manifest>

manifest整个项目中用到了Github上面的许多开源项目,如Litepal,OKhttp,这些都在build grade中引用过,代码贴出:
基于Android平台的图书管理系统的制作

文章图片
基于Android平台的图书管理系统的制作

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

build gradle整个管理系统无论是哪个用户,哪一个功能都离不开数据,这些数据都存储在本地的数据库里。关于数据库的设计是这样的:
1 < ?xml version="1.0" encoding="utf-8"?> 2 < litepal> 3< dbname value="https://www.songbingjia.com/android/library"> < /dbname> 4< version value="https://www.songbingjia.com/android/10"> < /version> 5< list> 6< mapping class="com.example.administrator.library1.Student"> < /mapping> 7< mapping class="com.example.administrator.library1.Teacher"> < /mapping> 8< mapping class="com.example.administrator.library1.Book"> < /mapping> 9< mapping class="com.example.administrator.library1.Staff"> < /mapping> 10< mapping class="com.example.administrator.library1.Simple"> < /mapping> 11< /list> 12 < /litepal>

library库由五个表构成:学生、教师(停用)、书籍、职员、简单信息(用于存储记住密码之后的账号、密码信息)组成。
  下一篇,我将来讲述学生的注册、登录、借还书功能的实现。
  (先附上整个项目的源码地址:https://github.com/Guozhi-explore/androidlibrary)
 
 
 



    推荐阅读