标签:equal extend audio activity close == weight lin als
上一篇讲解了制作图书管理系统的初衷与要求,和app首页的代码。
下面来介绍图书管理系统的服务对象:学生
学生类的设计:
个人信息:账号、密码、姓名、学号、邮箱、年龄。
借阅信息:借阅总数(不超过十本)、借阅书籍的ID(数组)、借阅书籍的日期(数组)。
源码在此:
1 package com.example.administrator.library1; 2 3 import org.litepal.LitePal; 4 import org.litepal.crud.DataSupport; 5 import org.litepal.crud.LitePalSupport; 6 7 import java.util.ArrayList; 8 import java.util.List; 9 10 public class Student extends LitePalSupport{ 11 private int id; 12 private String account,name,password,student_ID,mailBox; 13 private int age,bookAmount; 14 private int bookList[]=new int[10]; 15 private int bookyear[]=new int[10]; 16 private int bookday[]=new int[10]; 17 18 public Student(String account, String password, String name, String student_ID, String mailBox, int age) 19 { 20 this.account=account; 21 this.password=password; 22 this.name=name; 23 this.student_ID=student_ID; 24 this.mailBox=mailBox; 25 this.age=age; 26 bookAmount=0; 27 for(int i=0;i<10;++i) 28 { 29 bookList[i]=0; 30 bookyear[i]=0; 31 bookday[i]=0; 32 } 33 } 34 public int getId() { 35 return id; 36 } 37 public void setId(int id) { 38 this.id = id; 39 } 40 public void setName(String name) { 41 this.name = name; 42 } 43 public void setAccount(String account) { 44 this.account = account; 45 } 46 public void setAge(int age) { 47 this.age = age; 48 } 49 public void setPassword(String password) { 50 this.password = password; 51 } 52 public void setMailBox(String mailBox) { 53 this.mailBox = mailBox; 54 } 55 public void setStudent_ID(String student_ID) { 56 this.student_ID = student_ID; 57 } 58 public String getName() { 59 return name; 60 } 61 public int getAge() { 62 return age; 63 } 64 public String getAccount() { 65 return account; 66 } 67 public String getPassword() { 68 return password; 69 } 70 public String getStudent_ID() { 71 return student_ID; 72 } 73 public String getMailBox() { 74 return mailBox; 75 } 76 public void setBookList(int[] bookList) { 77 this.bookList = bookList; 78 } 79 public void setBookList(int number,int book_id) 80 { 81 this.bookList[number]=book_id; 82 } 83 public int[] getBookList() { 84 return bookList; 85 } 86 public int getBookAmount() { 87 return bookAmount; 88 } 89 public void setBookAmount(int bookAmount) { 90 this.bookAmount = bookAmount; 91 } 92 public int getBookList(int number) 93 { 94 return bookList[number]; 95 } 96 public int getBookyear(int number){return bookyear[number];} 97 public int getBookday(int number){return bookday[number];} 98 public void setBookyear(int number,int year){this.bookyear[number]=year;} 99 public void setBookday(int number,int day){this.bookday[number]=day;} 100 101 }
学生的注册:
注册有个人信息的填写:账号、密码(重复输入)、学号、姓名、邮箱、年龄。
代码如下:
主逻辑:
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.View; 7 import android.widget.Button; 8 import android.widget.EditText; 9 import android.widget.Toast; 10 11 import org.litepal.LitePal; 12 13 import java.util.List; 14 15 public class Register_student extends AppCompatActivity { 16 private EditText editAccount,editPassword1,editPassword2,editName,editMailbox,editAge,editStudentID; 17 private Button button_commit; 18 @Override 19 protected void onCreate(Bundle savedInstanceState) { 20 super.onCreate(savedInstanceState); 21 setContentView(R.layout.activity_register_student); 22 editAccount=findViewById(R.id.reg_st_acc_id); 23 editPassword1=findViewById(R.id.reg_st_pass1_id); 24 editPassword2=findViewById(R.id.reg_st_pass2_id); 25 editName=findViewById(R.id.reg_st_name_id); 26 editAge=findViewById(R.id.reg_st_age_id); 27 editMailbox=findViewById(R.id.reg_st_mail_id); 28 editStudentID=findViewById(R.id.reg_st_ID_id); 29 button_commit=findViewById(R.id.reg_st_commit_id); 30 button_commit.setOnClickListener(new View.OnClickListener() { 31 @Override 32 public void onClick(View view) { 33 if(editAccount.getText().toString().equals("")||editPassword1.getText().toString().equals("")||editPassword2.getText().toString().equals("")||editName.getText().toString().equals("")||editAge.getText().toString().equals("")||editMailbox.getText().toString().equals("")||editStudentID.getText().toString().equals("")) 34 { 35 Toast.makeText(Register_student.this,"注册信息不能为空",Toast.LENGTH_SHORT); 36 } 37 else 38 { 39 if(editAccount.getText().toString().length()>=6&&editAccount.getText().toString().length()<=12) 40 { 41 List<Student> students_account= LitePal.findAll(Student.class); 42 boolean differ=true; 43 for(int i=0;i<students_account.size();++i) 44 { 45 if(editAccount.getText().toString().equals(students_account.get(i).getAccount())) 46 { 47 Toast.makeText(Register_student.this,"账号已存在",Toast.LENGTH_SHORT).show(); 48 differ=false; 49 } 50 } 51 if(differ==true) 52 { 53 if(editPassword2.getText().toString().equals(editPassword1.getText().toString())) 54 { 55 int reg_age=Integer.parseInt(editAge.getText().toString()); 56 Student student=new Student(editAccount.getText().toString(),editPassword1.getText().toString(),editName.getText().toString(),editStudentID.getText().toString(),editMailbox.getText().toString(),reg_age); 57 student.save(); 58 Intent intent=new Intent(Register_student.this,MainActivity.class); 59 startActivity(intent); 60 //Toast.makeText(Register_student.this,"注册成功",Toast.LENGTH_SHORT).show(); 61 } 62 else 63 { 64 Toast.makeText(Register_student.this,"两次密码不相同",Toast.LENGTH_SHORT).show(); 65 } 66 } 67 } 68 else 69 { 70 Toast.makeText(Register_student.this,"账号大小需要在6-12位数之间",Toast.LENGTH_SHORT).show(); 71 } 72 } 73 74 } 75 }); 76 } 77 78 @Override 79 protected void onPause() { 80 Intent intent=new Intent(Register_student.this,MainActivity.class); 81 startActivity(intent); 82 super.onPause(); 83 } 84 }
界面:
1 <?xml version="1.0" encoding="utf-8"?> 2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 3 xmlns:app="http://schemas.android.com/apk/res-auto" 4 xmlns:tools="http://schemas.android.com/tools" 5 android:orientation="vertical" 6 android:layout_width="match_parent" 7 android:layout_height="match_parent" 8 tools:context=".Register_student"> 9 <LinearLayout 10 android:layout_marginTop="20dp" 11 android:orientation="horizontal" 12 android:layout_width="match_parent" 13 android:layout_height="wrap_content"> 14 <TextView 15 android:layout_width="0dp" 16 android:layout_height="match_parent" 17 android:layout_weight="1" 18 android:text="账号 :" 19 android:textSize="21sp"/> 20 <EditText 21 android:id="@+id/reg_st_acc_id" 22 android:layout_width="0dp" 23 android:layout_height="match_parent" 24 android:inputType="number" 25 android:digits="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890*/@#$%^" 26 android:layout_weight="3"/> 27 </LinearLayout> 28 <LinearLayout 29 android:orientation="horizontal" 30 android:layout_width="match_parent" 31 android:layout_height="wrap_content"> 32 <TextView 33 android:layout_width="0dp" 34 android:layout_height="match_parent" 35 android:layout_weight="1" 36 android:text="输入密码" 37 android:textSize="18sp"/> 38 <EditText 39 android:id="@+id/reg_st_pass1_id" 40 android:layout_width="0dp" 41 android:layout_height="match_parent" 42 android:inputType="textPassword" 43 android:digits="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890*/@#$%^" 44 android:layout_weight="3"/> 45 </LinearLayout> 46 <LinearLayout 47 android:orientation="horizontal" 48 android:layout_width="match_parent" 49 android:layout_height="wrap_content"> 50 <TextView 51 android:layout_width="0dp" 52 android:layout_height="match_parent" 53 android:layout_weight="1" 54 android:text="再输入密码" 55 android:textSize="18sp"/> 56 <EditText 57 android:id="@+id/reg_st_pass2_id" 58 android:layout_width="0dp" 59 android:layout_height="match_parent" 60 android:inputType="textPassword" 61 android:digits="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890*/@#$%^" 62 android:layout_weight="3"/> 63 </LinearLayout> 64 <LinearLayout 65 android:orientation="horizontal" 66 android:layout_width="match_parent" 67 android:layout_height="wrap_content"> 68 <TextView 69 android:layout_width="0dp" 70 android:layout_height="match_parent" 71 android:layout_weight="1" 72 android:text="姓名 :" 73 android:textSize="21sp"/> 74 <EditText 75 android:id="@+id/reg_st_name_id" 76 android:layout_width="0dp" 77 android:layout_height="match_parent" 78 android:layout_weight="3"/> 79 </LinearLayout> 80 <LinearLayout 81 android:orientation="horizontal" 82 android:layout_width="match_parent" 83 android:layout_height="wrap_content"> 84 <TextView 85 android:layout_width="0dp" 86 android:layout_height="match_parent" 87 android:layout_weight="1" 88 android:text="学号 :" 89 android:textSize="21sp"/> 90 <EditText 91 android:id="@+id/reg_st_ID_id" 92 android:inputType="number" 93 android:digits="1234567890" 94 android:layout_width="0dp" 95 android:layout_height="match_parent" 96 android:layout_weight="3"/> 97 </LinearLayout> 98 <LinearLayout 99 android:orientation="horizontal" 100 android:layout_width="match_parent" 101 android:layout_height="wrap_content"> 102 <TextView 103 android:layout_width="0dp" 104 android:layout_height="match_parent" 105 android:layout_weight="1" 106 android:text="邮箱 :" 107 android:textSize="21sp"/> 108 <EditText 109 android:id="@+id/reg_st_mail_id" 110 android:digits="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890@." 111 android:layout_width="0dp" 112 android:inputType="number" 113 android:layout_height="match_parent" 114 android:layout_weight="3"/> 115 </LinearLayout> 116 <LinearLayout 117 android:orientation="horizontal" 118 android:layout_width="match_parent" 119 android:layout_height="wrap_content"> 120 <TextView 121 android:layout_width="0dp" 122 android:layout_height="match_parent" 123 android:layout_weight="1" 124 android:text="年龄 :" 125 android:textSize="21sp"/> 126 <EditText 127 android:id="@+id/reg_st_age_id" 128 android:layout_width="0dp" 129 android:layout_height="match_parent" 130 android:layout_weight="3" 131 android:inputType="number"/> 132 </LinearLayout> 133 <Button 134 android:id="@+id/reg_st_commit_id" 135 android:layout_width="150dp" 136 android:layout_height="wrap_content" 137 android:textSize="24sp" 138 android:layout_gravity="center" 139 android:gravity="center" 140 android:text="注册提交"/> 141 </LinearLayout>
界面很丑,截图如下:
注册成功之后,将会使用开源项目Litepal将Edittext里的内容储存至本地数据库。Intent将活动带回MainActivity。
学生的登录:
使用账号密码登录,记住密码自动开启,并将账号和密码通过Simple类储存至Library数据库Simple表的第一列,登录开始时,会自动先访问Simple表ID为1的simple获得数据,登陆成功后进入Student homepage。
逻辑代码:
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.util.Log; 7 import android.view.View; 8 import android.widget.Button; 9 import android.widget.CheckBox; 10 import android.widget.EditText; 11 import android.widget.Toast; 12 13 import org.litepal.LitePal; 14 import org.litepal.crud.LitePalSupport; 15 16 import java.util.List; 17 18 public class Login_student extends AppCompatActivity { 19 20 private EditText editAccount,editPassword; 21 private CheckBox checkBox; 22 private Button button_commit; 23 @Override 24 protected void onCreate(Bundle savedInstanceState) { 25 super.onCreate(savedInstanceState); 26 setContentView(R.layout.activity_login_student); 27 editAccount=findViewById(R.id.accountStudent_id); 28 editPassword=findViewById(R.id.passwordStudent_id); 29 checkBox=findViewById(R.id.rememberPassStudent_id); 30 button_commit=findViewById(R.id.commitStudent_id); 31 32 //自动登录功能 33 final Simple simple=LitePal.find(Simple.class,1); 34 editAccount.setText(simple.getAccount()); 35 editPassword.setText(simple.getPassword()); 36 37 button_commit.setOnClickListener(new View.OnClickListener() { 38 @Override 39 public void onClick(View view) { //在这里之前已经出错 40 List<Student> students_account= LitePal.findAll(Student.class); 41 boolean is_account_available=false; 42 String st_account,st_password; 43 st_account=editAccount.getText().toString(); 44 st_password=editPassword.getText().toString(); 45 for(int i=0;i<students_account.size();++i) 46 { 47 if(st_account.equals(students_account.get(i).getAccount())) 48 { 49 is_account_available=true; 50 if(st_password.equals(students_account.get(i).getPassword())) 51 { 52 if(checkBox.isChecked()) 53 { 54 Simple simple= LitePal.find(Simple.class,1); 55 simple.setAccount(editAccount.getText().toString()); 56 simple.setPassword(editPassword.getText().toString()); 57 simple.save(); 58 } 59 else 60 { 61 Simple simple1=LitePal.find(Simple.class,1); 62 simple1.setAccount(""); 63 simple1.setPassword(""); 64 simple1.save(); 65 } 66 Intent intent=new Intent(Login_student.this,Student_homepage.class); 67 intent.putExtra("extra_data",i+1); 68 startActivity(intent); 69 finish(); 70 } 71 else 72 { 73 Toast.makeText(Login_student.this,"密码错误",Toast.LENGTH_SHORT).show(); 74 break; //记住密码还没有用上 75 } 76 } 77 } 78 if(is_account_available==false) 79 { 80 Toast.makeText(Login_student.this,"账号不存在",Toast.LENGTH_SHORT).show(); 81 } 82 } 83 84 }); 85 } 86 }
界面代码:
1 <?xml version="1.0" encoding="utf-8"?> 2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 3 xmlns:app="http://schemas.android.com/apk/res-auto" 4 android:orientation="vertical" 5 xmlns:tools="http://schemas.android.com/tools" 6 android:layout_width="match_parent" 7 android:layout_height="match_parent" 8 tools:context=".Login_student"> 9 10 <ImageView 11 android:layout_width="match_parent" 12 android:layout_height="211dp" 13 android:src="@drawable/img_login" /> 14 <LinearLayout 15 android:layout_width="match_parent" 16 android:layout_height="wrap_content" 17 android:layout_marginTop="20dp" 18 android:layout_marginLeft="20dp" 19 android:layout_marginRight="20dp" 20 android:orientation="horizontal"> 21 <TextView 22 android:layout_width="0dp" 23 android:layout_height="match_parent" 24 android:layout_weight="1" 25 android:textSize="21sp" 26 android:text="账号: "/> 27 <EditText 28 android:id="@+id/accountStudent_id" 29 android:layout_width="0dp" 30 android:layout_height="match_parent" 31 android:layout_weight="5" 32 android:hint="type here"/> 33 </LinearLayout> 34 <LinearLayout 35 android:orientation="horizontal" 36 android:layout_width="match_parent" 37 android:layout_marginLeft="20dp" 38 android:layout_marginRight="20dp" 39 android:layout_height="wrap_content"> 40 <TextView 41 android:layout_width="0dp" 42 android:layout_height="match_parent" 43 android:layout_weight="1" 44 android:textSize="21sp" 45 android:text="密码 :"/> 46 <EditText 47 android:id="@+id/passwordStudent_id" 48 android:layout_width="0dp" 49 android:layout_height="match_parent" 50 android:layout_weight="5" 51 android:hint="type here"/> 52 </LinearLayout> 53 <LinearLayout 54 android:layout_marginLeft="20dp" 55 android:layout_marginRight="20dp" 56 android:layout_width="match_parent" 57 android:layout_height="wrap_content"> 58 <CheckBox 59 android:id="@+id/rememberPassStudent_id" 60 android:checked="true" 61 android:layout_width="wrap_content" 62 android:layout_height="wrap_content" /> 63 <TextView 64 android:layout_width="wrap_content" 65 android:layout_height="wrap_content" 66 android:textSize="18sp" 67 android:text="自动登录"/> 68 </LinearLayout> 69 <Button 70 android:id="@+id/commitStudent_id" 71 android:layout_width="150dp" 72 android:layout_height="wrap_content" 73 android:layout_gravity="center" 74 android:textSize="20sp" 75 android:text="登录"/> 76 </LinearLayout>
学生空间:
学生空间包含的功能有:查询书籍、借书和还书。通过在数据库Book表中查询用户输入的书籍名称达到查询目的,查询成功后书籍出现,此时用户点击借阅即可借走该书,学生空间下面有listview控件,用来展示学生已经借阅未归还的书籍。用户点击listview里的书籍后,该书从listview中消失,用户账号里的bookamount-1,id[],data[],中关于该书的信息消失。
界面源码:
1 <?xml version="1.0" encoding="utf-8"?> 2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 3 xmlns:app="http://schemas.android.com/apk/res-auto" 4 xmlns:tools="http://schemas.android.com/tools" 5 android:layout_width="match_parent" 6 android:layout_height="match_parent" 7 android:orientation="vertical" 8 tools:context=".Student_homepage"> 9 10 <ImageView 11 android:layout_width="match_parent" 12 android:layout_height="160dp" 13 android:src="@drawable/img_1" /> 14 <TextView 15 android:id="@+id/stu_home_infor_id" 16 android:layout_width="match_parent" 17 android:layout_height="wrap_content" 18 android:textSize="20sp"/> 19 <LinearLayout 20 android:layout_marginTop="20dp" 21 android:layout_width="match_parent" 22 android:layout_height="wrap_content" 23 android:orientation="horizontal"> 24 <Button 25 android:id="@+id/stu_home_ser_id" 26 android:layout_width="wrap_content" 27 android:layout_height="wrap_content" 28 android:text="搜索" 29 android:textSize="18sp"/> 30 <EditText 31 android:id="@+id/stu_home_ser_content_id" 32 android:layout_width="0dp" 33 android:layout_height="wrap_content" 34 android:layout_weight="1" 35 android:hint="输入书名或者作者"/> 36 </LinearLayout> 37 <LinearLayout 38 android:id="@+id/stu_linear_id" 39 android:visibility="invisible" 40 android:orientation="horizontal" 41 android:layout_width="match_parent" 42 android:layout_height="wrap_content"> 43 <TextView 44 android:id="@+id/stu_home_book_id" 45 android:layout_width="0dp" 46 android:layout_height="wrap_content" 47 android:layout_weight="4"/> 48 <Button 49 android:id="@+id/stu_home_borrow_id" 50 android:layout_width="0dp" 51 android:layout_height="wrap_content" 52 android:layout_weight="1" 53 android:text="借阅" 54 android:textSize="20sp"/> 55 </LinearLayout> 56 <ListView 57 android:id="@+id/st_home_list_id" 58 android:layout_width="match_parent" 59 android:layout_height="match_parent"> 60 </ListView> 61 62 63 </LinearLayout>
逻辑代码:
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.support.v7.widget.LinearLayoutManager; 7 import android.support.v7.widget.RecyclerView; 8 import android.view.View; 9 import android.widget.Adapter; 10 import android.widget.AdapterView; 11 import android.widget.ArrayAdapter; 12 import android.widget.Button; 13 import android.widget.EditText; 14 import android.widget.LinearLayout; 15 import android.widget.ListView; 16 import android.widget.TextView; 17 import android.widget.Toast; 18 19 import org.litepal.LitePal; 20 21 import java.sql.Time; 22 import java.util.ArrayList; 23 import java.util.Calendar; 24 import java.util.List; 25 26 import static android.media.CamcorderProfile.get;// 27 //应该是书的数据没有存进去。 28 29 public class Student_homepage extends AppCompatActivity { 30 private int book_id[]=new int[10]; 31 Student student_local; 32 private List<String> bookList=new ArrayList<>(); 33 private Book book_in_search,book_in_delete; 34 int student_id; 35 boolean key=false; 36 private TextView text_student_infor,text_book_infor; 37 private Button search,borrow; 38 private EditText search_content; 39 private LinearLayout linearLayout; 40 @Override 41 protected void onCreate(Bundle savedInstanceState) { 42 super.onCreate(savedInstanceState); 43 setContentView(R.layout.activity_student_homepage); 44 45 for(int i=0;i<10;++i) 46 { 47 book_id[i]=0; 48 } 49 50 linearLayout=(LinearLayout)findViewById(R.id.stu_linear_id); 51 text_student_infor=(TextView)findViewById(R.id.stu_home_infor_id); 52 search_content=(EditText) findViewById(R.id.stu_home_ser_content_id); 53 text_book_infor=(TextView)findViewById(R.id.stu_home_book_id); 54 borrow=(Button)findViewById(R.id.stu_home_borrow_id); 55 search=(Button)findViewById(R.id.stu_home_ser_id); //注册控件 56 57 Intent intent=getIntent(); //获得上一个活动的数据 58 student_id=intent.getIntExtra("extra_data",1); 59 student_local=LitePal.find(Student.class,student_id); 60 text_student_infor.setText("学号:"+student_local.getStudent_ID()+" "+"姓名:"+student_local.getName()); 61 62 for(int i=0;i<student_local.getBookAmount();++i) 63 { 64 bookList.add(LitePal.find(Book.class,student_local.getBookList(i)).getName()); 65 book_id[i]=student_local.getBookList(i); 66 } 67 68 final ListView listView=(ListView) findViewById(R.id.st_home_list_id); 69 final ArrayAdapter<String> adapter=new ArrayAdapter<String>(Student_homepage.this,android.R.layout.simple_list_item_1,bookList); 70 listView.setAdapter(adapter); //制作listview滚动 71 72 listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { 73 @Override 74 public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { 75 String string = bookList.get(i); 76 Toast.makeText(Student_homepage.this, string+"归还成功", Toast.LENGTH_SHORT).show(); 77 bookList.remove(i); 78 for (int key = i; key < student_local.getBookAmount() - 1; ++key) { 79 book_id[key] = book_id[key + 1]; 80 } 81 student_local.setBookAmount(student_local.getBookAmount() - 1); 82 student_local.setBookList(book_id); 83 student_local.save(); 84 //List<Book> books = LitePal.where("name like ?", string).find(Book.class); 85 book_in_delete=LitePal.find(Book.class,book_id[i]); 86 int current_book = book_in_delete.getIn_shelf(); 87 book_in_delete.setIn_shelf(current_book + 1); 88 book_in_delete.save(); 89 90 listView.setAdapter(adapter); 91 } 92 }); 93 94 search.setOnClickListener(new View.OnClickListener() { 95 @Override 96 public void onClick(View view) { 97 String sear_book_name; 98 sear_book_name=search_content.getText().toString(); 99 List<Book> books=LitePal.where("name like ?",sear_book_name).find(Book.class); 100 if(books.size()>0) { 101 book_in_search = books.get(0); 102 text_book_infor.setText("书名:" + book_in_search.getName() + " " + "作者:" + book_in_search.getWriter()); 103 linearLayout.setVisibility(View.VISIBLE); 104 key=true; 105 } 106 } 107 }); 108 borrow.setOnClickListener(new View.OnClickListener() { 109 @Override 110 public void onClick(View view) { 111 if (book_in_search.getIn_shelf() > 0&&key==true) { 112 key=false; 113 if (student_local.getBookAmount() < 10) { 114 book_in_search.setIn_shelf(book_in_search.getIn_shelf() - 1); 115 book_in_search.save(); 116 book_id[student_local.getBookAmount()] = book_in_search.getId(); 117 bookList.add(book_in_search.getName()); 118 119 Calendar calendar=Calendar.getInstance(); 120 int year=calendar.get(Calendar.YEAR); 121 int day=calendar.get(Calendar.DAY_OF_YEAR); //获得当前的时间 122 123 student_local.setBookList(student_local.getBookAmount(),book_in_search.getId()); 124 student_local.setBookyear(student_local.getBookAmount(),year); 125 student_local.setBookday(student_local.getBookAmount(),day); 126 student_local.setBookAmount(student_local.getBookAmount()+1); 127 student_local.save(); 128 listView.setAdapter(adapter); 129 Toast.makeText(Student_homepage.this, "借书成功", Toast.LENGTH_SHORT).show(); 130 } else { 131 Toast.makeText(Student_homepage.this, "借书数目已达到上限,请还书后再借", Toast.LENGTH_SHORT).show(); 132 } 133 } else { 134 Toast.makeText(Student_homepage.this, "该书已经全部被借出", Toast.LENGTH_SHORT).show(); 135 } 136 } 137 }); 138 139 } 140 }
截图如下:
下一篇再来讲述Book与staff(工作人员)这两部分的实现。
标签:equal extend audio activity close == weight lin als
原文地址:https://www.cnblogs.com/Gzxjt/p/9648532.html