一、JAVA文件
1.Announcement_Page.java
package com.example.myapplication;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class Announcement_Pgae extends AppCompatActivity {
private Button button_return;
private Button button_confirm;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.announcement_page);
button_return = findViewById(R.id.button_return);
button_confirm = findViewById(R.id.button_confirm);
button_return.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent_return = new Intent(getApplicationContext(), MainActivity.class);
startActivity((intent_return));
}
});
button_confirm.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent_return = new Intent(getApplicationContext(), MainActivity.class);
startActivity((intent_return));
}
});
}
}
2.Borrow_books_Page.java
package com.example.myapplication;
import androidx.appcompat.app.AppCompatActivity;
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class Borrow_books_Page extends AppCompatActivity {
private Button button_return;
private Spinner spinner;
private String search_pattern;
private EditText editText_search;
private Button button_search;
private ListView listView;
private SQLiteDatabase database;
private List<Map<String,Object>> mData;
private String user;
private String name;
private SharedPreferences sp;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.borrow_books_page);
button_return = findViewById(R.id.button_return);
spinner = findViewById(R.id.spinner);
editText_search = findViewById(R.id.editText_search);
button_search = findViewById(R.id.button_search);
listView = findViewById(R.id.listView);
Database_user database_user= new Database_user(Borrow_books_Page.this);
database = database_user.getWritableDatabase();
sp = getSharedPreferences("LibrarySystem", Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sp.edit();
user = sp.getString("user","");
name = sp.getString("name","");
button_return.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
Intent intent_return = new Intent(getApplicationContext(), MainActivity.class);
startActivity(intent_return);
}
});
spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
search_pattern = adapterView.getItemAtPosition(i).toString();
}
@Override
public void onNothingSelected(AdapterView<?> adapterView) {
}
});
button_search.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
mData = getData();
MyAdapter adapter = new MyAdapter(getApplicationContext());
listView.setAdapter(adapter);
// Booklist = new ArrayList<>();
// String sql = "select * from books where 书名 like ?";
// if(search_pattern.equals("责任者")){
// sql = "select * from books where 责任者 like ?";
// }
// else if(search_pattern.equals("出版信息")){
// sql = "select * from books where 出版信息 like ?";
// }
// Cursor cursor = database.rawQuery(sql,new String[]{'%'+EditText_search.getText().toString()+'%'});
// while(cursor.moveToNext()){
// Map<String,Object> map = new HashMap<>();
// int book_name_ColumnIndex = cursor.getColumnIndex("书名");
// String book_name_searched = cursor.getString(book_name_ColumnIndex);
// int book_author_ColumnIndex = cursor.getColumnIndex("责任者");
// String book_author_searched = cursor.getString(book_author_ColumnIndex);
// int book_publisher_ColumnIndex = cursor.getColumnIndex("出版信息");
// String book_publisher_searched = cursor.getString(book_publisher_ColumnIndex);
// int book_count_ColumnIndex = cursor.getColumnIndex("借阅册次");
// String book_count_searched = cursor.getString(book_count_ColumnIndex);
// int book_state_ColumnIndex = cursor.getColumnIndex("是否借出");
// String book_state_searched = cursor.getString(book_state_ColumnIndex);
// map.put("book_name",book_name_searched);
// map.put("book_author",book_author_searched);
// map.put("book_publisher",book_publisher_searched);
// map.put("book_count","借阅册次:"+book_count_ColumnIndex);
// map.put("book_state","是否借出:"+book_state_searched);
// Booklist.add(map);
// }
// adapter= new SimpleAdapter(getApplicationContext(),Booklist,R.layout.simpleadapter_books,new String[]{"book_name","book_author","book_publisher","book_count","book_state"},new int[]{R.id.textView_book_name,R.id.textView_book_author,R.id.textView_book_publisher,R.id.textView_book_count,R.id.textView_book_state});
}
});
}
public class MyAdapter extends BaseAdapter{
private LayoutInflater mInflater;
public MyAdapter(Context context) {
this.mInflater = LayoutInflater.from((Context) context);
}
@Override
public int getCount() {
return mData.size();
}
@Override
public Object getItem(int i) {
return null;
}
@Override
public long getItemId(int i) {
return 0;
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
ViewHolder holder = null;
if (convertView == null) {
holder=new ViewHolder();
//可以理解为从vlist获取view 之后把view返回给ListView
convertView = mInflater.inflate(R.layout.adapter_books, null);
holder.book_name = (TextView)convertView.findViewById(R.id.textView_book_name);
holder.book_author = (TextView)convertView.findViewById(R.id.textView_book_author);
holder.book_publisher = (TextView) convertView.findViewById(R.id.textView_book_publisher);
holder.book_count = (TextView)convertView.findViewById(R.id.textView_book_count);
holder.book_state = (TextView)convertView.findViewById(R.id.textView_book_state);
holder.button_borrow = (Button)convertView.findViewById(R.id.button_borrow);
convertView.setTag(holder);
}else {
holder = (ViewHolder)convertView.getTag();
}
holder.book_name.setText((String)mData.get(position).get("book_name"));
holder.book_author.setText((String)mData.get(position).get("book_author"));
holder.book_publisher.setText((String)mData.get(position).get("book_publisher"));
holder.book_count.setText("借阅册次:" + (String)mData.get(position).get("book_count"));
holder.book_state.setText("是否借出:" + (String)mData.get(position).get("book_state"));
holder.button_borrow.setTag(position);
//给Button添加单击事件 添加Button之后ListView将失去焦点 需要的直接把Button的焦点去掉
ViewHolder finalHolder = holder;
holder.button_borrow.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (mData.get(position).get("book_state").toString().equals("是")) {
Toast.makeText(Borrow_books_Page.this, "已被借出,请重新选择", Toast.LENGTH_SHORT).show();
} else {
String sql = "select * from borrow_books where 学号=? and 是否归还=?";
Cursor cursor = database.rawQuery(sql, new String[]{user,"否"});
if (cursor.getCount() == 3) {
Toast.makeText(Borrow_books_Page.this, "已借三本书,请归还后再借", Toast.LENGTH_SHORT).show();
} else {
Calendar calendar = Calendar.getInstance();
int year = calendar.get(Calendar.YEAR);
int month = calendar.get(Calendar.MONTH) + 1;
int day = calendar.get(Calendar.DAY_OF_MONTH);
ContentValues values = new ContentValues();
values.put("学号",user);
values.put("姓名",name);
values.put("书名", mData.get(position).get("book_name").toString());
values.put("借书日期",Integer.toString(year)+"-"+Integer.toString(month)+"-"+Integer.toString(day));
values.put("是否归还", "否");
values.put("还书日期","未归还");
values.put("是否逾期", "否");
database.insert("borrow_books", null, values);
String stl1 = "update books set 是否借出=?,借出人学号=?,借出人姓名=? where 书名=?";
database.execSQL(stl1, new Object[]{"是", user, name, mData.get(position).get("book_name").toString()});
String stl2 = "select * from user where 学号=?";
Cursor cursor1 = database.rawQuery(stl2,new String[]{user});
cursor1.moveToFirst();
int countColumnIndex = cursor1.getColumnIndex("借书次数");
int count = cursor1.getInt(countColumnIndex) + 1;
String stl3 = "update user set 借书次数=? where 学号=?";
database.execSQL(stl3,new Object[]{count,user});
String stl4 = "select * from books where 书名=?";
Cursor cursor2 = database.rawQuery(stl4,new String[]{mData.get(position).get("book_name").toString()});
cursor2.moveToFirst();
int book_countColumnIndex = cursor2.getColumnIndex("借阅册次");
int book_count = cursor2.getInt(book_countColumnIndex) + 1;
String stl5="update books set 借阅册次=? where 书名=?";
database.execSQL(stl5,new Object[]{book_count,mData.get(position).get("book_name").toString()});
Toast.makeText(Borrow_books_Page.this, "借书成功", Toast.LENGTH_SHORT).show();
}
}
}
});
//holder.viewBtn.setOnClickListener(MyListener(position));
return convertView;
}
}
private List<Map<String, Object>> getData() {
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
String sql = "select * from books where 书名 like ?";
if(search_pattern.equals("责任者")){
sql = "select * from books where 责任者 like ?";
}
else if(search_pattern.equals("出版信息")){
sql = "select * from books where 出版信息 like ?";
}
Cursor cursor = database.rawQuery(sql,new String[]{'%'+editText_search.getText().toString()+'%'});
while(cursor.moveToNext()){
Map<String,Object> map = new HashMap<>();
int book_name_ColumnIndex = cursor.getColumnIndex("书名");
String book_name_searched = cursor.getString(book_name_ColumnIndex);
int book_author_ColumnIndex = cursor.getColumnIndex("责任者");
String book_author_searched = cursor.getString(book_author_ColumnIndex);
int book_publisher_ColumnIndex = cursor.getColumnIndex("出版信息");
String book_publisher_searched = cursor.getString(book_publisher_ColumnIndex);
int book_count_ColumnIndex = cursor.getColumnIndex("借阅册次");
String book_count_searched = cursor.getString(book_count_ColumnIndex);
int book_state_ColumnIndex = cursor.getColumnIndex("是否借出");
String book_state_searched = cursor.getString(book_state_ColumnIndex);
map.put("book_name",book_name_searched);
map.put("book_author",book_author_searched);
map.put("book_publisher",book_publisher_searched);
map.put("book_count",book_count_searched);
map.put("book_state",book_state_searched);
list.add(map);
}
return list;
}
public final class ViewHolder{
TextView book_name;
TextView book_author;
TextView book_publisher;
TextView book_count;
TextView book_state;
Button button_borrow;
}
}
3.Database_user.java
package com.example.myapplication;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import androidx.annotation.Nullable;
public class Database_user extends SQLiteOpenHelper {
public Database_user(@Nullable Context context) {
super(context, "user.db", null, 1);
}
@Override
public void onCreate(SQLiteDatabase sqLiteDatabase) {
// String sql="CREATE TABLE [user](\n" +
// " [学号] varchar(50) UNIQUE, \n" +
// " [姓名] varchar(50), \n" +
// " [密码] varchar(50), \n" +
// " [学习次数] INT, \n" +
// " [借书次数] INT)";
// sqLiteDatabase.execSQL(sql);
// String sql1="CREATE TABLE [study](\n" +
// " [学号] varchar(50), \n" +
// " [姓名] varchar(50), \n" +
// " [年] varchar(20), \n" +
// " [月] varchar(20), \n" +
// " [日] varchar(20), \n" +
// " [时刻] varchar(20))";
// sqLiteDatabase.execSQL(sql1);
// String sql2="CREATE TABLE [borrow_books](\n" +
// " [学号] varchar(50), \n" +
// " [姓名] varchar(50), \n" +
// " [书名] varchar(100), \n" +
// " [借书日期] VARCHAR(20), \n" +
// " [是否归还] varchar(20), \n" +
// " [还书日期] VARCHAR(20), \n" +
// " [是否逾期] varchar(20))";
// sqLiteDatabase.execSQL(sql2);
// String sql3="CREATE TABLE [books](\n" +
// " [书名] VARCHAR(100) UNIQUE, \n" +
// " [责任者] VARCHAR(100), \n" +
// " [出版信息] VARCHAR(100), \n" +
// " [借阅册次] INT, \n" +
// " [是否借出] VARCHAR(20), \n" +
// " [借出人学号] VARCHAR(50), \n" +
// " [借出人姓名] VARCHAR(50))";
// sqLiteDatabase.execSQL(sql3);
}
@Override
public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {
}
}
4.Login_Page.java
package com.example.myapplication;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.Toast;
public class Login_Page extends AppCompatActivity {
private Button button_sign_in;
private Button button_register;
private EditText editText_user;
private EditText editText_password;
private SQLiteDatabase database;
private SharedPreferences sp;
private CheckBox checkbox_remember_user;
private CheckBox checkbox_remember_password;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.login_page);
Database_user database_user= new Database_user(Login_Page.this);
database = database_user.getWritableDatabase();
button_sign_in = findViewById(R.id.button_sign_in);
button_register = findViewById(R.id.button_register);
editText_user = findViewById(R.id.editText_user);
editText_password = findViewById(R.id.editText_password);
checkbox_remember_user = findViewById(R.id.checkBox_remember_user);
checkbox_remember_password = findViewById(R.id.checkBox_remember_password);
sp = getSharedPreferences("LibrarySystem", Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sp.edit();
if(sp.getBoolean("remember_user_selected",true)){
editText_user.setText(sp.getString("user_saved",""));
checkbox_remember_user.setChecked(true);
}
if(sp.getBoolean("remember_password_selected",true)){
editText_password.setText(sp.getString("password_saved",""));
checkbox_remember_password.setChecked(true);
}
button_sign_in.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String sql="select * from user where 学号=?";
Cursor cursor = database.rawQuery(sql,new String[]{editText_user.getText().toString()});
if(cursor.getCount()==0){
Toast.makeText(getApplicationContext(), "学号尚未注册", Toast.LENGTH_SHORT).show();
editText_user.setText("");
}else{
cursor.moveToFirst();
int passwordColumnIndex = cursor.getColumnIndex("密码");
String password_saved = cursor.getString(passwordColumnIndex);
if(password_saved.equals(editText_password.getText().toString())){
int nameColumnIndex = cursor.getColumnIndex("姓名");
String name = cursor.getString(nameColumnIndex);
editor.putString("name",name);
editor.putString("user",editText_user.getText().toString());
if(checkbox_remember_user.isChecked()){
editor.putString("user_saved",editText_user.getText().toString());
editor.putBoolean("remember_user_selected",true);
}else{
editor.putBoolean("remember_user_selected",false);
}
if(checkbox_remember_password.isChecked()){
editor.putString("password_saved",editText_password.getText().toString());
editor.putBoolean("remember_password_selected",true);
}else{
editor.putBoolean("remember_password_selected",false);
}
editor.commit();
Intent intent_sign_in = new Intent(getApplicationContext(), MainActivity.class);
startActivity(intent_sign_in);
}else{
Toast.makeText(getApplicationContext(), "密码错误", Toast.LENGTH_SHORT).show();
editText_password.setText("");
}
}
}
});
button_register.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent_register = new Intent(getApplicationContext(), Register_Page.class);
startActivity(intent_register);
}
});
}
}
5.MainAcitivity.java
package com.example.myapplication;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import java.text.SimpleDateFormat;
import java.util.Calendar;
public class MainActivity extends AppCompatActivity {
private TextView textView_current_time2;
private TextView textView_hello;
private TextView textView_name;
private TextView textView_hello2;
private Button button_return;
private String timeString;
private String hello;
private String hello2;
private Button button_study;
private Button button_borrow;
private Button button_record;
private Button button_return_book;
private Button button_announcement;
private Button button_modify_password;
private String name;
private SharedPreferences sp;
Handler handler = new Handler(){
@Override
public void handleMessage(@NonNull Message msg) {
super.handleMessage(msg);
if(msg.what==0x00){
String time = (String) msg.obj;
textView_current_time2.setText(time);
}
}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
textView_current_time2 = findViewById(R.id.textView_current_time2);
textView_hello = findViewById(R.id.textView_hello);
textView_name = findViewById(R.id.textView_name);
textView_hello2 = findViewById(R.id.textView_hello2);
button_return = findViewById(R.id.button_return);
button_study = findViewById(R.id.button_study);
button_borrow = findViewById(R.id.button_borrow);
button_record = findViewById(R.id.button_record);
button_return_book = findViewById(R.id.button_return_book);
button_announcement = findViewById(R.id.button_announcement);
button_modify_password = findViewById(R.id.button_modify_password);
sp = getSharedPreferences("LibrarySystem", Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sp.edit();
name = sp.getString("name","");
button_return.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent_return = new Intent(getApplicationContext(), Login_Page.class);
startActivity(intent_return);
}
});
button_study.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent_announcement = new Intent(getApplicationContext(), Study_Page.class);
startActivity((intent_announcement));
}
});
button_borrow.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent_borrow = new Intent(getApplicationContext(), Borrow_books_Page.class);
startActivity((intent_borrow));
}
});
button_modify_password.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent_modify_password = new Intent(getApplicationContext(), Modify_password_Pgae.class);
startActivity(intent_modify_password);
}
});
button_return_book.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent_return_book = new Intent(getApplicationContext(), Return_books_Page.class);
startActivity(intent_return_book);
}
});
button_record.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent_record= new Intent(getApplicationContext(), Rank_Page.class);
startActivity(intent_record);
}
});
button_announcement.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent_announcement = new Intent(getApplicationContext(), Announcement_Pgae.class);
startActivity(intent_announcement);
}
});
Calendar calendar = Calendar.getInstance();
int hour = calendar.get(Calendar.HOUR_OF_DAY);
if(hour>=6 && hour<12){
hello = "早上好,";
hello2 = ",早晨朝气蓬勃!";
}else if(hour>=12 && hour<18)
{
hello = "下午好,";
hello2 = ",下午继续坚持!";
}else if(hour>=18 && hour<24){
hello = "晚上好,";
hello2 = ",夜晚孜孜不倦!";
}else{
hello = "深夜好,";
hello2 = ",深夜早点休息!";
}
textView_hello.setText(hello);
textView_name.setText(name);
textView_hello2.setText(hello2);
new Thread(){
@Override
public void run() {
super.run();
while(true){
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
timeString = simpleDateFormat.format(System.currentTimeMillis());
Message message = new Message();
message.what = 0x00;
message.obj = timeString;
handler.sendMessage(message);
try {
sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
};
}.start();
}
}
6.Modify_[assword_Page.java
package com.example.myapplication;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class Modify_password_Pgae extends AppCompatActivity {
private Button button_return;
private EditText editText_password_old;
private EditText editText_password_new;
private EditText editText_password_new_again;
private Button button_confirm;
private SQLiteDatabase database;
private String user;
private SharedPreferences sp;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.modify_password_page);
button_return = findViewById(R.id.button_return);
editText_password_old = findViewById(R.id.editText_password_old);
editText_password_new = findViewById(R.id.editText_password_new);
editText_password_new_again = findViewById(R.id.editText_password_new_again);
button_confirm = findViewById(R.id.button_confirm);
Database_user database_user= new Database_user(Modify_password_Pgae.this);
database = database_user.getWritableDatabase();
sp = getSharedPreferences("LibrarySystem", Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sp.edit();
user = sp.getString("user","");
button_return.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent_return = new Intent(getApplicationContext(), MainActivity.class);
startActivity(intent_return);
}
});
button_confirm.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(editText_password_old.getText().toString().equals("") || editText_password_new.getText().toString().equals("") || editText_password_new_again.getText().toString().equals("")){
Toast.makeText(Modify_password_Pgae.this, "请输入密码信息", Toast.LENGTH_SHORT).show();
}else{
String sql = "select * from user where 学号=?";
Cursor cursor = database.rawQuery(sql,new String[]{user});
cursor.moveToFirst();
int passwordColumnIndex = cursor.getColumnIndex("密码");
if(editText_password_old.getText().toString().equals(cursor.getString(passwordColumnIndex))){
if(editText_password_new.getText().toString().equals(editText_password_new_again.getText().toString())){
String sql1 = "update user set 密码=? where 学号=?";
database.execSQL(sql1,new Object[]{editText_password_new.getText().toString(),user});
Toast.makeText(Modify_password_Pgae.this, "修改成功", Toast.LENGTH_SHORT).show();
Intent intent_return = new Intent(getApplicationContext(), Login_Page.class);
startActivity(intent_return);
}else{
Toast.makeText(Modify_password_Pgae.this, "新密码不一致", Toast.LENGTH_SHORT).show();
editText_password_new.setText("");
editText_password_new_again.setText("");
}
}else{
Toast.makeText(Modify_password_Pgae.this, "原密码错误", Toast.LENGTH_SHORT).show();
editText_password_old.setText("");
}
}
}
});
}
}
7.Rank_Page.java
package com.example.myapplication;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class Rank_Page extends AppCompatActivity {
private Button button_return;
private ListView listView_borrow;
private ListView listView_study;
private SQLiteDatabase database;
private List<Map<String,Object>> mData_borrow;
private List<Map<String,Object>> mData_study;
private String user;
private SharedPreferences sp;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.rank_page);
button_return = findViewById(R.id.button_return);
listView_borrow = findViewById(R.id.listView_borrow);
listView_study = findViewById(R.id.listView_study);
Database_user database_user= new Database_user(Rank_Page.this);
database = database_user.getWritableDatabase();
sp = getSharedPreferences("LibrarySystem", Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sp.edit();
user = sp.getString("user","");
button_return.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent_return= new Intent(getApplicationContext(), MainActivity.class);
startActivity(intent_return);
}
});
mData_borrow = getData_borrow();
MyAdapter_borrow adapter_borrow = new MyAdapter_borrow(getApplicationContext());
listView_borrow.setAdapter(adapter_borrow);
mData_study = getData_study();
MyAdapter_study adapter_study = new MyAdapter_study(getApplicationContext());
listView_study.setAdapter(adapter_study);
}
public class MyAdapter_borrow extends BaseAdapter {
private LayoutInflater mInflater;
public MyAdapter_borrow(Context context) {
this.mInflater = LayoutInflater.from((Context) context);
}
@Override
public int getCount() {
return mData_borrow.size();
}
@Override
public Object getItem(int i) {
return null;
}
@Override
public long getItemId(int i) {
return 0;
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
ViewHolder_rank holder = null;
if (convertView == null) {
holder=new ViewHolder_rank();
//可以理解为从vlist获取view 之后把view返回给ListView
convertView = mInflater.inflate(R.layout.adapter_rank, null);
holder.user = (TextView)convertView.findViewById(R.id.textView_user);
holder.name = (TextView)convertView.findViewById(R.id.textView_name);
holder.rank = (TextView)convertView.findViewById(R.id.textView_rank);
holder.times = (TextView)convertView.findViewById(R.id.textView_times);
convertView.setTag(holder);
}else {
holder = (ViewHolder_rank)convertView.getTag();
}
holder.user.setText("学号:" + (String)mData_borrow.get(position).get("rank_user"));
holder.name.setText("姓名:" + (String)mData_borrow.get(position).get("rank_name"));
holder.rank.setText((String)mData_borrow.get(position).get("rank_rank"));
holder.times.setText("借书次数:" + (String)mData_borrow.get(position).get("rank_borrow_times"));
ViewHolder_rank finalHolder = holder;
//holder.viewBtn.setOnClickListener(MyListener(position));
return convertView;
}
}
public class MyAdapter_study extends BaseAdapter {
private LayoutInflater mInflater;
public MyAdapter_study(Context context) {
this.mInflater = LayoutInflater.from((Context) context);
}
@Override
public int getCount() {
return mData_study.size();
}
@Override
public Object getItem(int i) {
return null;
}
@Override
public long getItemId(int i) {
return 0;
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
ViewHolder_rank holder = null;
if (convertView == null) {
holder=new ViewHolder_rank();
//可以理解为从vlist获取view 之后把view返回给ListView
convertView = mInflater.inflate(R.layout.adapter_rank, null);
holder.user = (TextView)convertView.findViewById(R.id.textView_user);
holder.name = (TextView)convertView.findViewById(R.id.textView_name);
holder.rank = (TextView)convertView.findViewById(R.id.textView_rank);
holder.times = (TextView)convertView.findViewById(R.id.textView_times);
convertView.setTag(holder);
}else {
holder = (ViewHolder_rank)convertView.getTag();
}
holder.user.setText("学号:" + (String)mData_study.get(position).get("rank_user"));
holder.name.setText("姓名:" + (String)mData_study.get(position).get("rank_name"));
holder.rank.setText((String)mData_study.get(position).get("rank_rank"));
holder.times.setText("学习次数:" + (String)mData_study.get(position).get("rank_borrow_times"));
ViewHolder_rank finalHolder = holder;
//holder.viewBtn.setOnClickListener(MyListener(position));
return convertView;
}
}
private List<Map<String, Object>> getData_borrow() {
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
String sql = "select * from user order by 借书次数 desc";
Cursor cursor = database.rawQuery(sql,new String[]{});
int count = 0;
while(cursor.moveToNext()){
count++;
if(count > 3) break;
Map<String,Object> map = new HashMap<>();
int userColumnIndex = cursor.getColumnIndex("学号");
String rank_user = cursor.getString(userColumnIndex);
int nameColumnIndex = cursor.getColumnIndex("姓名");
String rank_name = cursor.getString(nameColumnIndex);
int timesColumnIndex = cursor.getColumnIndex("借书次数");
int rank_borrow_times = cursor.getInt(timesColumnIndex);
String rank_borrow_times_ = Integer.toString(rank_borrow_times);
map.put("rank_user",rank_user);
map.put("rank_name",rank_name);
map.put("rank_rank","排 名\n "+Integer.toString(count));
map.put("rank_borrow_times",rank_borrow_times_);
list.add(map);
}
String sql1 = "select * from user order by 借书次数 desc";
Cursor cursor1 = database.rawQuery(sql1,new String[]{});
int count_ = 0;
while(cursor1.moveToNext()) {
count_++;
int userColumnIndex = cursor1.getColumnIndex("学号");
String rank_user = cursor1.getString(userColumnIndex);
if(rank_user.equals(user)){
Map<String, Object> map = new HashMap<>();
int nameColumnIndex = cursor.getColumnIndex("姓名");
String rank_name = cursor1.getString(nameColumnIndex);
int timesColumnIndex = cursor1.getColumnIndex("借书次数");
int rank_borrow_times = cursor1.getInt(timesColumnIndex);
String rank_borrow_times_ = Integer.toString(rank_borrow_times);
map.put("rank_user", rank_user);
map.put("rank_name", rank_name);
map.put("rank_rank", "我 的\n排 名\n "+Integer.toString(count_));
map.put("rank_borrow_times", rank_borrow_times_);
list.add(map);
break;
}
}
return list;
}
private List<Map<String, Object>> getData_study() {
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
String sql = "select * from user order by 学习次数 desc";
Cursor cursor = database.rawQuery(sql,new String[]{});
int count = 0;
while(cursor.moveToNext()){
count++;
if(count > 3) break;
Map<String,Object> map = new HashMap<>();
int userColumnIndex = cursor.getColumnIndex("学号");
String rank_user = cursor.getString(userColumnIndex);
int nameColumnIndex = cursor.getColumnIndex("姓名");
String rank_name = cursor.getString(nameColumnIndex);
int timesColumnIndex = cursor.getColumnIndex("学习次数");
int rank_borrow_times = cursor.getInt(timesColumnIndex);
String rank_borrow_times_ = Integer.toString(rank_borrow_times);
map.put("rank_user",rank_user);
map.put("rank_name",rank_name);
map.put("rank_rank","排 名\n "+Integer.toString(count));
map.put("rank_borrow_times",rank_borrow_times_);
list.add(map);
}
String sql1 = "select * from user order by 学习次数 desc";
Cursor cursor1 = database.rawQuery(sql1,new String[]{});
int count_ = 0;
while(cursor1.moveToNext()) {
count_++;
int userColumnIndex = cursor1.getColumnIndex("学号");
String rank_user = cursor1.getString(userColumnIndex);
if(rank_user.equals(user)){
Map<String, Object> map = new HashMap<>();
int nameColumnIndex = cursor.getColumnIndex("姓名");
String rank_name = cursor1.getString(nameColumnIndex);
int timesColumnIndex = cursor1.getColumnIndex("学习次数");
int rank_borrow_times = cursor1.getInt(timesColumnIndex);
String rank_borrow_times_ = Integer.toString(rank_borrow_times);
map.put("rank_user", rank_user);
map.put("rank_name", rank_name);
map.put("rank_rank", "我 的\n排 名\n "+Integer.toString(count_));
map.put("rank_borrow_times", rank_borrow_times_);
list.add(map);
break;
}
}
return list;
}
public final class ViewHolder_rank{
TextView user;
TextView name;
TextView times;
TextView rank;
}
}
8.Register_Page.java
package com.example.myapplication;
import androidx.appcompat.app.AppCompatActivity;
import android.content.ContentValues;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class Register_Page extends AppCompatActivity {
private SQLiteDatabase database;
private EditText editText_user;
private EditText editText_name;
private EditText editText_password;
private EditText editText_password_again;
private Button button_confirm;
private Button button_return;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.register_page);
editText_user = findViewById(R.id.editText_user);
editText_name = findViewById(R.id.editText_name);
editText_password = findViewById(R.id.editText_password);
editText_password_again = findViewById(R.id.editText_password_again);
button_confirm = findViewById(R.id.button_confirm);
button_return = findViewById(R.id.button_return);
Database_user database_user= new Database_user(Register_Page.this);
database = database_user.getWritableDatabase();
button_confirm.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(!editText_user.getText().toString().equals("") && !editText_name.getText().toString().equals("") && !editText_password.getText().toString().equals("") && !editText_password_again.getText().toString().equals("")){
insert(view);
}else{
Toast.makeText(getApplicationContext(),"请输入完整注册信息",Toast.LENGTH_SHORT).show();
}
}
});
button_return.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent_return = new Intent(getApplicationContext(), Login_Page.class);
startActivity(intent_return);
}
});
}
public void insert(View view){
String sql = "select * from user where 学号=?";
Cursor cursor = database.rawQuery(sql,new String[]{editText_user.getText().toString()});
if(cursor.getCount()==0){
if(editText_password.getText().toString().equals(editText_password_again.getText().toString())){
ContentValues values = new ContentValues();
values.put("学号",editText_user.getText().toString());
values.put("姓名",editText_name.getText().toString());
values.put("密码",editText_password.getText().toString());
values.put("学习次数",0);
values.put("借书次数",0);
database.insert("user",null,values);
Intent intent_return = new Intent(getApplicationContext(), Login_Page.class);
Toast.makeText(getApplicationContext(),"注册成功",Toast.LENGTH_SHORT).show();
startActivity(intent_return);
}else{
Toast.makeText(getApplicationContext(),"两次密码输入不一致,请重新输入",Toast.LENGTH_SHORT).show();
editText_password.setText("");
editText_password_again.setText("");
}
}else{
Toast.makeText(getApplicationContext(),"学号已存在,请重新输入",Toast.LENGTH_SHORT).show();
editText_user.setText("");
}
}
}
9.Return_books_Page.java
package com.example.myapplication;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class Return_books_Page extends AppCompatActivity {
private Button button_return;
private Button button_refresh;
private ListView listView_borrow;
private ListView listView_return;
private SQLiteDatabase database;
private List<Map<String,Object>> mData_borrow;
private List<Map<String,Object>> mData_return;
private String user;
private SharedPreferences sp;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.return_books_page);
button_return = findViewById(R.id.button_return);
button_refresh = findViewById(R.id.button_refresh);
Database_user database_user= new Database_user(Return_books_Page.this);
database = database_user.getWritableDatabase();
listView_borrow = findViewById(R.id.listView_borrow);
listView_return = findViewById(R.id.listView_return);
sp = getSharedPreferences("LibrarySystem", Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sp.edit();
user = sp.getString("user","");
mData_borrow = getData_borrow();
MyAdapter_borrow adapter_borrow = new MyAdapter_borrow(getApplicationContext());
listView_borrow.setAdapter(adapter_borrow);
mData_return = getData_return();
MyAdapter_return adapter_return = new MyAdapter_return(getApplicationContext());
listView_return.setAdapter(adapter_return);
button_return.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
Intent intent_return = new Intent(getApplicationContext(), MainActivity.class);
startActivity(intent_return);
}
});
button_refresh.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
mData_borrow = getData_borrow();
MyAdapter_borrow adapter_borrow = new MyAdapter_borrow(getApplicationContext());
listView_borrow.setAdapter(adapter_borrow);
mData_return = getData_return();
MyAdapter_return adapter_return = new MyAdapter_return(getApplicationContext());
listView_return.setAdapter(adapter_return);
}
});
}
public class MyAdapter_return extends BaseAdapter {
private LayoutInflater mInflater;
public MyAdapter_return(Context context) {
this.mInflater = LayoutInflater.from((Context) context);
}
@Override
public int getCount() {
return mData_return.size();
}
@Override
public Object getItem(int i) {
return null;
}
@Override
public long getItemId(int i) {
return 0;
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
ViewHolder_return holder = null;
if (convertView == null) {
holder=new ViewHolder_return();
//可以理解为从vlist获取view 之后把view返回给ListView
convertView = mInflater.inflate(R.layout.adapter_books_return, null);
holder.book_name = (TextView)convertView.findViewById(R.id.textView_book_name);
holder.book_borrow_time = (TextView)convertView.findViewById(R.id.textView_book_borrow_time);
holder.book_return_time = (TextView)convertView.findViewById(R.id.textView_book_return_time);
holder.book_state = (TextView)convertView.findViewById(R.id.textView_book_state);
convertView.setTag(holder);
}else {
holder = (ViewHolder_return)convertView.getTag();
}
holder.book_name.setText((String)mData_return.get(position).get("book_name"));
holder.book_borrow_time.setText("借出日期:" + (String)mData_return.get(position).get("book_borrow_time"));
holder.book_return_time.setText("归还日期:" + (String)mData_return.get(position).get("book_return_time"));
holder.book_state.setText("是否逾期:" + (String)mData_return.get(position).get("book_state"));
ViewHolder_return finalHolder = holder;
//holder.viewBtn.setOnClickListener(MyListener(position));
return convertView;
}
}
public class MyAdapter_borrow extends BaseAdapter {
private LayoutInflater mInflater;
public MyAdapter_borrow(Context context) {
this.mInflater = LayoutInflater.from((Context) context);
}
@Override
public int getCount() {
return mData_borrow.size();
}
@Override
public Object getItem(int i) {
return null;
}
@Override
public long getItemId(int i) {
return 0;
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
ViewHolder_borrow holder = null;
if (convertView == null) {
holder = new ViewHolder_borrow();
//可以理解为从vlist获取view 之后把view返回给ListView
convertView = mInflater.inflate(R.layout.adapter_books_borrow, null);
holder.book_name = (TextView) convertView.findViewById(R.id.textView_book_name);
holder.book_borrow_time = (TextView) convertView.findViewById(R.id.textView_book_borrow_time);
holder.book_state = (TextView) convertView.findViewById(R.id.textView_book_state);
holder.button_return = (Button) convertView.findViewById(R.id.button_return);
convertView.setTag(holder);
} else {
holder = (ViewHolder_borrow) convertView.getTag();
}
holder.book_name.setText((String) mData_borrow.get(position).get("book_name"));
holder.book_borrow_time.setText("借出日期:" + (String) mData_borrow.get(position).get("book_borrow_time"));
holder.book_state.setText("是否逾期:" + (String) mData_borrow.get(position).get("book_state"));
holder.button_return.setTag(position);
//给Button添加单击事件 添加Button之后ListView将失去焦点 需要的直接把Button的焦点去掉
ViewHolder_borrow finalHolder = holder;
holder.button_return.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String book_name = (String) mData_borrow.get(position).get("book_name");
Calendar calendar = Calendar.getInstance();
int year = calendar.get(Calendar.YEAR);
int month = calendar.get(Calendar.MONTH) + 1;
int day = calendar.get(Calendar.DAY_OF_MONTH);
String book_return_time = Integer.toString(year) + "-" +Integer.toString(month) + "-" + Integer.toString(day);
String sql = "update borrow_books set 是否归还=?,还书日期=? where 学号=? and 书名=?";
database.execSQL(sql,new Object[]{"是",book_return_time,user,(String)mData_borrow.get(position).get("book_name")});
String sql1 = "update books set 是否借出=?,借出人学号=?,借出人姓名=? where 书名=?";
database.execSQL(sql1,new Object[]{"否","无","无",(String)mData_borrow.get(position).get("book_name")});
Toast.makeText(Return_books_Page.this, "还书成功", Toast.LENGTH_SHORT).show();
}
});
//holder.viewBtn.setOnClickListener(MyListener(position));
return convertView;
}
}
private List<Map<String, Object>> getData_return() {
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
String sql = "select * from borrow_books where 学号=? and 是否归还=?";
Cursor cursor = database.rawQuery(sql,new String[]{user,"是"});
while(cursor.moveToNext()){
Map<String,Object> map = new HashMap<>();
int book_name_ColumnIndex = cursor.getColumnIndex("书名");
String book_name_searched = cursor.getString(book_name_ColumnIndex);
int book_borrow_time_ColumnIndex = cursor.getColumnIndex("借书日期");
String book_borrow_time_searched = cursor.getString(book_borrow_time_ColumnIndex);
int book_return_time_ColumnIndex = cursor.getColumnIndex("还书日期");
String book_return_time_searched = cursor.getString(book_return_time_ColumnIndex);
int book_state_ColumnIndex = cursor.getColumnIndex("是否逾期");
String book_state_searched = cursor.getString(book_state_ColumnIndex);
map.put("book_name",book_name_searched);
map.put("book_borrow_time",book_borrow_time_searched);
map.put("book_return_time",book_return_time_searched);
map.put("book_state",book_state_searched);
list.add(map);
}
return list;
}
private List<Map<String, Object>> getData_borrow() {
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
String sql = "select * from borrow_books where 学号=? and 是否归还=?";
Cursor cursor = database.rawQuery(sql,new String[]{user,"否"});
while(cursor.moveToNext()){
Map<String,Object> map = new HashMap<>();
int book_name_ColumnIndex = cursor.getColumnIndex("书名");
String book_name_searched = cursor.getString(book_name_ColumnIndex);
int book_borrow_time_ColumnIndex = cursor.getColumnIndex("借书日期");
String book_borrow_time_searched = cursor.getString(book_borrow_time_ColumnIndex);
String[] book_borrow_time = book_borrow_time_searched.split("-");
int year_picked = Integer.parseInt(book_borrow_time[0]);
int month_picked = Integer.parseInt(book_borrow_time[1]);
int day_picked = Integer.parseInt(book_borrow_time[2]);
Calendar calendar = Calendar.getInstance();
int year = calendar.get(Calendar.YEAR);
int month = calendar.get(Calendar.MONTH) + 1;
int day = calendar.get(Calendar.DAY_OF_MONTH);
int time_current = (year-1) * 365 + day;
if(month > 1){
time_current += 31;
}
if(month > 2){
time_current += 28;
}
if(month > 3){
time_current += 31;
}
if(month > 4){
time_current += 30;
}
if(month > 5){
time_current += 31;
}
if(month > 6){
time_current += 30;
}
if(month > 7){
time_current += 31;
}
if(month> 8){
time_current += 31;
}
if(month > 9){
time_current += 30;
}
if(month > 10){
time_current += 31;
}
if(month > 11){
time_current += 30;
}
int time_picked = (year_picked-1) * 365 + day_picked;
if(month_picked > 1){
time_picked += 31;
}
if(month_picked > 2){
time_picked += 28;
}
if(month_picked > 3){
time_picked += 31;
}
if(month_picked > 4){
time_picked += 30;
}
if(month_picked > 5){
time_picked += 31;
}
if(month_picked > 6){
time_picked += 30;
}
if(month_picked > 7){
time_picked += 31;
}
if(month_picked > 8){
time_picked += 31;
}
if(month_picked > 9){
time_picked += 30;
}
if(month_picked > 10){
time_picked += 31;
}
if(month_picked > 11){
time_picked += 30;
}
String book_state;
if(time_current > time_picked +30){
book_state = "是";
}else{
book_state = "否";
}
map.put("book_name",book_name_searched);
map.put("book_borrow_time",book_borrow_time_searched);
map.put("book_state",book_state);
list.add(map);
}
return list;
}
public final class ViewHolder_return{
TextView book_name;
TextView book_borrow_time;
TextView book_return_time;
TextView book_state;
}
public final class ViewHolder_borrow{
TextView book_name;
TextView book_borrow_time;
TextView book_state;
Button button_return;
}
}
10.Study_Page.java
package com.example.myapplication;
import androidx.appcompat.app.AppCompatActivity;
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.Toast;
import java.util.Calendar;
public class Study_Page extends AppCompatActivity {
private SQLiteDatabase database;
private DatePicker datePicker;
private int year_current;
private int month_current;
private int day_current;
private int year_picked;
private int month_picked;
private int day_picked;
private Button button_confirm;
private Button button_return;
private RadioGroup radioGroup;
private RadioButton radioButton;
private String shike;
private String user;
private String name;
private SharedPreferences sp;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.study_page);
datePicker = findViewById(R.id.datapicker);
button_confirm = findViewById(R.id.button_confirm);
Database_user database_user= new Database_user(Study_Page.this);
database = database_user.getWritableDatabase();
radioGroup = findViewById(R.id.RadioGroup);
button_return = findViewById(R.id.button_return);
sp = getSharedPreferences("LibrarySystem", Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sp.edit();
user = sp.getString("user","");
name = sp.getString("name","");
Calendar calendar = Calendar.getInstance();
int year = calendar.get(Calendar.YEAR);
int month = calendar.get(Calendar.MONTH);
int day = calendar.get(Calendar.DAY_OF_MONTH);
year_current = year;
month_current = month+1;
day_current = day;
datePicker.init(year, month, day, new DatePicker.OnDateChangedListener() {
@Override
public void onDateChanged(DatePicker datePicker, int i, int i1, int i2) {
year_picked = i;
month_picked = (i1+1);
day_picked = i2;
}
});
button_return.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent_return = new Intent(getApplicationContext(), MainActivity.class);
startActivity(intent_return);
}
});
button_confirm.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
int time_current = (year_current-1) * 365 + day_current;
if(month_current > 1){
time_current += 31;
}
if(month_current > 2){
time_current += 28;
}
if(month_current > 3){
time_current += 31;
}
if(month_current > 4){
time_current += 30;
}
if(month_current > 5){
time_current += 31;
}
if(month_current > 6){
time_current += 30;
}
if(month_current > 7){
time_current += 31;
}
if(month_current > 8){
time_current += 31;
}
if(month_current > 9){
time_current += 30;
}
if(month_current > 10){
time_current += 31;
}
if(month_current > 11){
time_current += 30;
}
int time_picked = (year_picked-1) * 365 + day_picked;
if(month_picked > 1){
time_picked += 31;
}
if(month_picked > 2){
time_picked += 28;
}
if(month_picked > 3){
time_picked += 31;
}
if(month_picked > 4){
time_picked += 30;
}
if(month_picked > 5){
time_picked += 31;
}
if(month_picked > 6){
time_picked += 30;
}
if(month_picked > 7){
time_picked += 31;
}
if(month_picked > 8){
time_picked += 31;
}
if(month_picked > 9){
time_picked += 30;
}
if(month_picked > 10){
time_picked += 31;
}
if(month_picked > 11){
time_picked += 30;
}
if(time_picked <= time_current || time_picked - time_current > 3){
Toast.makeText(Study_Page.this, "请选择三天之内的时间预约自习", Toast.LENGTH_SHORT).show();
}else{
for(int i=0;i<radioGroup.getChildCount();i++){
radioButton = (RadioButton) radioGroup.getChildAt(i);
if(radioButton.isChecked()){
shike = radioButton.getText().toString();
}
}
String sql = "select * from study where 年=? and 月=? and 日=? and 时刻=?";
Cursor cursor = database.rawQuery(sql,new String[]{Integer.toString(year_picked),Integer.toString(month_picked),Integer.toString(day_picked),shike});
if(cursor.getCount()>10){
Toast.makeText(Study_Page.this, "当前日期时间段预约自习人数已满,请重新选择", Toast.LENGTH_SHORT).show();
}else{
int flag = 1;
while(cursor.moveToNext())
{
int yearColumnIndex = cursor.getColumnIndex("年");
String year_saved = cursor.getString(yearColumnIndex);
int monthColumnIndex = cursor.getColumnIndex("月");
String month_saved = cursor.getString(monthColumnIndex);
int dayColumnIndex = cursor.getColumnIndex("日");
String day_saved = cursor.getString(dayColumnIndex);
int shikeColumnIndex = cursor.getColumnIndex("时刻");
String shike_saved = cursor.getString(shikeColumnIndex);
int userColumnIndex = cursor.getColumnIndex("学号");
String user_saved = cursor.getString(userColumnIndex);
if(year_saved.equals(Integer.toString(year_picked)) && month_saved.equals(Integer.toString(month_picked)) && day_saved.equals(Integer.toString(day_picked)) && shike_saved.equals(shike) && user_saved.equals(user)) {
Toast.makeText(Study_Page.this, "当前日期时间段已预约过,请重新选择", Toast.LENGTH_SHORT).show();
flag = 0;
break;
}
}
if(flag == 1){
ContentValues values = new ContentValues();
values.put("学号", user);
values.put("姓名", name);
values.put("年", Integer.toString(year_picked));
values.put("月", Integer.toString(month_picked));
values.put("日", Integer.toString(day_picked));
values.put("时刻", shike);
database.insert("study",null,values);
String sql1 = "select * from user where 学号=?";
Cursor cursor2 = database.rawQuery(sql1,new String[]{user});
cursor2.moveToFirst();
int timesColumnIndex = cursor2.getColumnIndex("学习次数");
int times = cursor2.getInt(timesColumnIndex) + 1;
String sql2 = "update user set 学习次数=? where 学号=?";
database.execSQL(sql2,new Object[]{times,user});
Toast.makeText(Study_Page.this, "预约自习成功", Toast.LENGTH_SHORT).show();
}
}
}
}
});
}
}
11.Welcome_Page.java
package com.example.myapplication;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
public class Welcome_Page extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.welcome_page);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
Intent intent = new Intent(getApplicationContext(), Login_Page.class);
startActivity(intent);
finish();
}
},3000);
}
}
二、layout文件xml
1.activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Login_Page"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="@color/lavenderblush"
>
<Button
android:id="@+id/button_return"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginLeft="5dp"
android:layout_marginTop="5dp"
android:background="@drawable/button_full_circle_shape"
android:text="←"
android:textColor="@color/whitesmoke"
android:textSize="25dp" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_toRightOf="@id/button_return"
android:layout_centerHorizontal="true"
android:text="Library System"
android:textColor="@color/darkorange"
android:textSize="50dp" />
<ImageView
android:id="@+id/imageView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/textView1"
android:layout_alignParentBottom="true"
app:srcCompat="@drawable/picture3" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="250dp"
android:layout_weight="1"
android:background="@color/lavenderblush">
<Button
android:id="@+id/button_modify_password"
android:layout_width="150dp"
android:layout_height="60dp"
android:layout_below="@id/button_record"
android:layout_marginLeft="30dp"
android:layout_marginTop="30dp"
android:layout_toRightOf="@id/button_announcement"
android:background="@drawable/button_rectangle"
android:text="修改密码"
android:textColor="@color/mediumslateblue"
android:textSize="25dp" />
<Button
android:id="@+id/button_announcement"
android:layout_width="150dp"
android:layout_height="60dp"
android:layout_below="@id/button_record"
android:layout_marginLeft="40dp"
android:layout_marginTop="30dp"
android:background="@drawable/button_rectangle"
android:text="公告栏"
android:textColor="@color/mediumslateblue"
android:textSize="25dp" />
<Button
android:id="@+id/button_return_book"
android:layout_width="150dp"
android:layout_height="60dp"
android:layout_below="@id/button_study"
android:layout_marginLeft="30dp"
android:layout_marginTop="30dp"
android:layout_toRightOf="@id/button_record"
android:background="@drawable/button_rectangle"
android:text="预约还书"
android:textColor="@color/mediumslateblue"
android:textSize="25dp" />
<Button
android:id="@+id/button_record"
android:layout_width="150dp"
android:layout_height="60dp"
android:layout_below="@id/button_study"
android:layout_marginLeft="40dp"
android:layout_marginTop="30dp"
android:background="@drawable/button_rectangle"
android:text="排行榜"
android:textColor="@color/mediumslateblue"
android:textSize="25dp" />
<Button
android:id="@+id/button_borrow"
android:layout_width="150dp"
android:layout_height="60dp"
android:layout_below="@id/textView_name"
android:layout_marginLeft="30dp"
android:layout_marginTop="40dp"
android:layout_toRightOf="@id/button_study"
android:background="@drawable/button_rectangle"
android:text="预约借书"
android:textColor="@color/mediumslateblue"
android:textSize="25dp" />
<Button
android:id="@+id/button_study"
android:layout_width="150dp"
android:layout_height="60dp"
android:layout_below="@id/textView_name"
android:layout_marginLeft="40dp"
android:layout_marginTop="40dp"
android:background="@drawable/button_rectangle"
android:text="预约自习"
android:textColor="@color/mediumslateblue"
android:textSize="25dp" />
<TextView
android:id="@+id/textView_hello2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/textView_current_time2"
android:layout_marginTop="15dp"
android:layout_toRightOf="@id/textView_name"
android:text="TextView"
android:textColor="@color/steelblue"
android:textSize="25dp" />
<TextView
android:id="@+id/textView_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/textView_current_time2"
android:layout_marginTop="15dp"
android:layout_toRightOf="@id/textView_hello"
android:text="TextView"
android:textColor="@color/steelblue"
android:textSize="25dp" />
<TextView
android:id="@+id/textView_hello"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/textView_current_time1"
android:layout_marginLeft="20dp"
android:layout_marginTop="15dp"
android:text="TextView"
android:textColor="@color/steelblue"
android:textSize="25dp" />
<TextView
android:id="@+id/textView_current_time2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginTop="15dp"
android:layout_toRightOf="@id/textView_current_time1"
android:text="TextView"
android:textColor="@color/steelblue"
android:textSize="25dp" />
<TextView
android:id="@+id/textView_current_time1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="15dp"
android:text="当前时间:"
android:textColor="@color/steelblue"
android:textSize="25dp" />
</RelativeLayout>
</LinearLayout>
2.adapter_books.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="150dp"
android:background="@color/lavenderblush">
<Button
android:id="@+id/button_borrow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginTop="60dp"
android:layout_marginRight="5dp"
android:background="@drawable/button_rectangle"
android:text="借阅"
android:textColor="@color/mediumslateblue"
android:textSize="25dp" />
<TextView
android:id="@+id/textView_book_state"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/textView_book_publisher"
android:layout_toRightOf="@id/textView_book_count"
android:layout_marginTop="10dp"
android:layout_marginLeft="30dp"
android:textSize="20dp"
android:textColor="@color/red"/>
<TextView
android:id="@+id/textView_book_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/textView_book_publisher"
android:layout_marginTop="10dp"
android:layout_marginLeft="10dp"
android:textSize="20dp"
android:textColor="@color/midnightblue"/>
<TextView
android:id="@+id/textView_book_publisher"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/textView_book_name"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:textColor="@color/midnightblue"
android:textSize="20dp" />
<TextView
android:id="@+id/textView_book_author"
android:layout_width="150dp"
android:layout_height="30dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:layout_toRightOf="@id/textView_book_name"
android:textColor="@color/midnightblue"
android:textSize="20dp" />
<TextView
android:id="@+id/textView_book_name"
android:layout_width="200dp"
android:layout_height="30dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:textColor="@color/midnightblue"
android:textSize="20dp" />
</RelativeLayout>
3.adapter_books_borrow.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="125dp"
android:orientation="horizontal"
android:background="@color/lavenderblush">
<Button
android:id="@+id/button_return"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="10dp"
android:layout_weight="1"
android:textColor="@color/steelblue"
android:background="@drawable/button_rectangle"
android:text="归还"
android:textSize="20dp"/>
<TextView
android:id="@+id/textView_book_name"
android:layout_width="230dp"
android:layout_height="30dp"
android:layout_marginLeft="20dp"
android:layout_marginTop="10dp"
android:layout_weight="1"
android:textColor="@color/steelblue"
android:textSize="20dp" />
<TextView
android:id="@+id/textView_book_borrow_time"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_below="@id/textView_book_name"
android:layout_marginLeft="20dp"
android:layout_marginTop="10dp"
android:layout_weight="1"
android:textSize="20dp"
android:textColor="@color/steelblue"
/>
<TextView
android:id="@+id/textView_book_state"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_below="@id/textView_book_borrow_time"
android:layout_marginLeft="20dp"
android:layout_marginTop="10dp"
android:textSize="20dp"
android:layout_weight="1"
android:textColor="@color/red"
/>
</RelativeLayout>
4.adapter_books_return.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="125dp"
android:orientation="horizontal"
android:background="@color/lavenderblush">
<TextView
android:id="@+id/textView_book_name"
android:layout_width="300dp"
android:layout_height="30dp"
android:layout_marginLeft="20dp"
android:layout_marginTop="10dp"
android:layout_weight="1"
android:textColor="@color/steelblue"
android:textSize="20dp" />
<TextView
android:id="@+id/textView_book_borrow_time"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_below="@id/textView_book_name"
android:layout_marginLeft="20dp"
android:layout_marginTop="10dp"
android:layout_weight="1"
android:textSize="20dp"
android:textColor="@color/steelblue"
/>
<TextView
android:id="@+id/textView_book_return_time"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_below="@id/textView_book_borrow_time"
android:layout_marginLeft="20dp"
android:layout_marginTop="10dp"
android:layout_weight="1"
android:textColor="@color/steelblue"
android:textSize="20dp" />
<TextView
android:id="@+id/textView_book_state"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_below="@id/textView_book_borrow_time"
android:layout_marginLeft="20dp"
android:layout_marginTop="10dp"
android:layout_toRightOf="@id/textView_book_return_time"
android:layout_weight="1"
android:textColor="@color/red"
android:textSize="20dp" />
</RelativeLayout>
5.adapter_rank.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="120dp"
android:orientation="horizontal"
android:background="@color/lavenderblush">
<TextView
android:id="@+id/textView_rank"
android:layout_width="100dp"
android:layout_height="120dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:textColor="@color/red"
android:textSize="30dp" />
<TextView
android:id="@+id/textView_times"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_below="@id/textView_name"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:layout_toRightOf="@id/textView_rank"
android:textColor="@color/red"
android:textSize="25dp" />
<TextView
android:id="@+id/textView_name"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_toRightOf="@+id/textView_rank"
android:layout_below="@id/textView_user"
android:layout_marginTop="5dp"
android:layout_marginLeft="10dp"
android:textColor="@color/mediumslateblue"
android:textSize="25dp"
/>
<TextView
android:id="@+id/textView_user"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_toRightOf="@id/textView_rank"
android:layout_marginTop="10dp"
android:layout_marginLeft="10dp"
android:textColor="@color/mediumslateblue"
android:textSize="25dp" />
</RelativeLayout>
6.announcement_page.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Announcement_Pgae"
android:background="@color/lavenderblush">
<TextView
android:id="@+id/textView_announcement"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_centerHorizontal="true"
android:textSize="40dp"
android:textColor="@color/midnightblue"
android:text="公 告 栏" />
<TextView
android:id="@+id/textView_announcement_1"
android:layout_width="400dp"
android:layout_height="wrap_content"
android:layout_below="@id/textView_announcement"
android:layout_marginStart="20dp"
android:layout_marginLeft="20dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="20dp"
android:layout_marginRight="20dp"
android:layout_marginBottom="20dp"
android:background="@drawable/text_background_1"
android:gravity="center"
android:text="公告1: 图书馆时间\n星期一到星期五\n08:00~21:00\n星期六到星期日\n07:00~10:30"
android:textColor="@color/olive"
android:textSize="30dp" />
<TextView
android:id="@+id/textView_announcement_2"
android:layout_width="400dp"
android:layout_height="wrap_content"
android:layout_below="@id/textView_announcement_1"
android:layout_marginLeft="20dp"
android:layout_marginTop="20dp"
android:layout_marginRight="20dp"
android:background="@drawable/text_background_1"
android:gravity="center"
android:text="公告2:因疫情防控需求,所有学生进入图书馆均需预约且佩戴口罩,间隔入座。"
android:textColor="@color/olive"
android:textSize="30dp" />
<TextView
android:id="@+id/textView_announcement_3"
android:layout_width="400dp"
android:layout_height="wrap_content"
android:layout_below="@id/textView_announcement_2"
android:layout_marginLeft="20dp"
android:layout_marginTop="20dp"
android:layout_marginRight="20dp"
android:background="@drawable/text_background_1"
android:gravity="center"
android:text="公告3:借书上限为三本,且还书期限为一个月,超出时间将被被记为逾期。"
android:textColor="@color/olive"
android:textSize="30dp" />
<Button
android:id="@+id/button_return"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginLeft="5dp"
android:layout_marginTop="5dp"
android:background="@drawable/button_full_circle_shape"
android:text="←"
android:textColor="@color/whitesmoke"
android:textSize="25dp" />
<Button
android:id="@+id/button_confirm"
android:layout_width="250dp"
android:layout_height="60dp"
android:layout_centerHorizontal="true"
android:layout_marginTop="30dp"
android:layout_below="@id/textView_announcement_3"
android:background="@drawable/button_full_circle_shape"
android:text="确认收到公告"
android:textColor="@color/whitesmoke"
android:textSize="30dp" />
</RelativeLayout>
7.borrow_books_page.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Borrow_books_Page"
android:background="@color/lavenderblush">
<ListView
android:id="@+id/listView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/editText_search"
android:layout_marginTop="20dp" />
<Button
android:id="@+id/button_search"
android:background="@drawable/button_circle_shape"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/editText_search"
android:layout_below="@id/spinner"
android:layout_marginTop="20dp"
android:layout_marginLeft="10dp"
android:textSize="30dp"
android:text="搜索" />
<EditText
android:id="@+id/editText_search"
android:layout_width="290dp"
android:layout_height="60dp"
android:layout_below="@id/textView_search_pattern"
android:layout_marginLeft="10dp"
android:layout_marginTop="20dp"
android:background="@drawable/text_background"
android:ems="10"
android:hint="请输入搜索信息"
android:inputType="textPersonName"
android:textColor="@color/steelblue"
android:textSize="30dp" />
<Spinner
android:id="@+id/spinner"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_marginLeft="20dp"
android:layout_marginTop="20dp"
android:layout_toRightOf="@id/textView_search_pattern"
android:entries="@array/search_pattern" />
<TextView
android:id="@+id/textView_search_pattern"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="20dp"
android:layout_toRightOf="@id/button_return"
android:text="搜索方式:"
android:textColor="@color/steelblue"
android:textSize="30dp" />
<Button
android:id="@+id/button_return"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginLeft="5dp"
android:layout_marginTop="5dp"
android:background="@drawable/button_full_circle_shape"
android:text="←"
android:textColor="@color/whitesmoke"
android:textSize="25dp" />
</RelativeLayout>
8.login_page.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:orientation="vertical"
android:background="@color/lavenderblush">
<TextView
android:id="@+id/textView_header"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginTop="1dp"
android:text="Library System"
android:textColor="@color/darkorange"
android:textSize="50dp"
android:layout_centerHorizontal="true"/>
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="250dp"
android:layout_below="@id/textView_header"
app:srcCompat="@drawable/picture1" />
<CheckBox
android:id="@+id/checkBox_remember_password"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/textView_password"
android:layout_toRightOf="@id/checkBox_remember_user"
android:layout_marginLeft="30dp"
android:textSize="30dp"
android:text="记住密码" />
<CheckBox
android:id="@+id/checkBox_remember_user"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/textView_password"
android:layout_marginLeft="40dp"
android:text="记住学号"
android:textSize="30dp" />
<Button
android:id="@+id/button_sign_in"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/checkBox_remember_user"
android:layout_marginLeft="150dp"
android:layout_marginTop="20dp"
android:background="@drawable/button_circle_shape"
android:text="登 录"
android:textColor="@color/whitesmoke"
android:textSize="30dp" />
<Button
android:id="@+id/button_register"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/button_sign_in"
android:layout_marginLeft="150dp"
android:layout_marginTop="20dp"
android:background="@drawable/button_circle_shape"
android:text="注 册"
android:textColor="@color/whitesmoke"
android:textSize="30dp" />
<EditText
android:id="@+id/editText_password"
android:layout_width="wrap_content"
android:layout_height="60dp"
android:layout_below="@id/editText_user"
android:layout_marginLeft="10dp"
android:layout_marginTop="20dp"
android:layout_toRightOf="@id/textView_password"
android:ems="10"
android:hint="请输入密码"
android:inputType="textPassword"
android:textSize="30dp" />
<EditText
android:id="@+id/editText_user"
android:layout_width="wrap_content"
android:layout_height="60dp"
android:layout_below="@id/imageView1"
android:layout_marginLeft="10dp"
android:layout_marginTop="20dp"
android:layout_toRightOf="@id/textView_user"
android:ems="10"
android:hint="请输入学号"
android:inputType="textPersonName"
android:textSize="30dp" />
<TextView
android:id="@+id/textView_user"
android:layout_width="wrap_content"
android:layout_height="60dp"
android:layout_below="@id/imageView1"
android:layout_marginTop="20dp"
android:gravity="center"
android:paddingLeft="15dp"
android:text="学 号:"
android:textColor="@color/darkorange"
android:textSize="30dp" />
<TextView
android:id="@+id/textView_password"
android:layout_width="wrap_content"
android:layout_height="60dp"
android:layout_below="@id/textView_user"
android:layout_marginTop="20dp"
android:gravity="center"
android:paddingLeft="15dp"
android:text="密 码:"
android:textColor="@color/darkorange"
android:textSize="30dp" />
</RelativeLayout>
9.modify_password_page.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/lavenderblush"
tools:context=".Modify_password_Pgae">
<ImageView
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="300dp"
android:layout_below="@id/button_return"
app:srcCompat="@drawable/picture4" />
<Button
android:id="@+id/button_return"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginLeft="5dp"
android:layout_marginTop="5dp"
android:background="@drawable/button_full_circle_shape"
android:text="←"
android:textColor="@color/whitesmoke"
android:textSize="25dp" />
<TextView
android:id="@+id/textView_password_old"
android:layout_width="wrap_content"
android:layout_height="60dp"
android:layout_below="@id/imageView"
android:layout_marginLeft="10dp"
android:gravity="center"
android:text="原密码:"
android:textColor="@color/darkorange"
android:textSize="30dp" />
<TextView
android:id="@+id/textView_password_new"
android:layout_width="wrap_content"
android:layout_height="60dp"
android:layout_below="@id/textView_password_old"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:gravity="center"
android:text="新密码:"
android:textColor="@color/darkorange"
android:textSize="30dp" />
<EditText
android:id="@+id/editText_password_old"
android:layout_width="wrap_content"
android:layout_height="60dp"
android:layout_below="@id/imageView"
android:layout_marginLeft="120dp"
android:ems="10"
android:hint="请输入原密码"
android:inputType="textPassword"
android:textSize="30dp" />
<EditText
android:id="@+id/editText_password_new"
android:layout_width="wrap_content"
android:layout_height="60dp"
android:layout_below="@id/editText_password_old"
android:layout_marginLeft="120dp"
android:layout_marginTop="10dp"
android:ems="10"
android:hint="请输入新密码"
android:inputType="textPassword"
android:textSize="30dp" />
<EditText
android:id="@+id/editText_password_new_again"
android:layout_width="wrap_content"
android:layout_height="60dp"
android:layout_below="@id/editText_password_new"
android:layout_marginLeft="120dp"
android:layout_marginTop="10dp"
android:ems="10"
android:hint="请再次输入新密码"
android:inputType="textPassword"
android:textSize="30dp" />
<Button
android:id="@+id/button_confirm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/editText_password_new_again"
android:layout_marginLeft="150dp"
android:layout_marginTop="30dp"
android:background="@drawable/button_circle_shape"
android:text="确 认"
android:textColor="@color/whitesmoke"
android:textSize="30dp" />
</RelativeLayout>
10.rank_page.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Rank_Page"
android:background="@color/lavenderblush">
<ListView
android:id="@+id/listView_borrow"
android:layout_width="match_parent"
android:layout_height="280dp"
android:layout_below="@id/textView_borrow_rank"
android:layout_marginTop="5dp"/>
<ListView
android:id="@+id/listView_study"
android:layout_width="match_parent"
android:layout_height="280dp"
android:layout_below="@id/textView_study_rank"
android:layout_marginTop="5dp" />
<TextView
android:id="@+id/textView_borrow_rank"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/listView_study"
android:layout_centerHorizontal="true"
android:layout_marginTop="5dp"
android:background="@drawable/text_background"
android:text="借书排行榜"
android:textColor="@color/orange"
android:textSize="30dp" />
<TextView
android:id="@+id/textView_study_rank"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/button_return"
android:layout_centerHorizontal="true"
android:layout_marginTop="5dp"
android:background="@drawable/text_background"
android:text="自习排行榜"
android:textColor="@color/orange"
android:textSize="30dp" />
<Button
android:id="@+id/button_return"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginLeft="5dp"
android:layout_marginTop="5dp"
android:background="@drawable/button_full_circle_shape"
android:text="←"
android:textColor="@color/whitesmoke"
android:textSize="25dp" />
</RelativeLayout>
11.register_page.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Register_Page"
android:background="@color/lavenderblush" >
<Button
android:id="@+id/button_confirm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/editText_password_again"
android:layout_marginLeft="150dp"
android:layout_marginTop="20dp"
android:background="@drawable/button_circle_shape"
android:text="确 认"
android:textColor="@color/whitesmoke"
android:textSize="30dp" />
<EditText
android:id="@+id/editText_user"
android:layout_width="wrap_content"
android:layout_height="60dp"
android:layout_below="@id/imageView1"
android:layout_marginLeft="10dp"
android:layout_marginTop="20dp"
android:layout_toRightOf="@id/textView_user"
android:ems="10"
android:hint="请输入学号"
android:inputType="textPersonName"
android:textSize="30dp" />
<EditText
android:id="@+id/editText_name"
android:layout_width="wrap_content"
android:layout_height="60dp"
android:layout_below="@id/editText_user"
android:layout_marginLeft="10dp"
android:layout_marginTop="20dp"
android:layout_toRightOf="@id/textView_name"
android:ems="10"
android:hint="请输入姓名"
android:inputType="textPersonName"
android:textSize="30dp" />
<EditText
android:id="@+id/editText_password"
android:layout_width="wrap_content"
android:layout_height="60dp"
android:layout_below="@id/editText_name"
android:layout_marginLeft="120dp"
android:layout_marginTop="20dp"
android:ems="10"
android:hint="请输入密码"
android:inputType="textPassword"
android:textSize="30dp" />
<EditText
android:id="@+id/editText_password_again"
android:layout_width="wrap_content"
android:layout_height="60dp"
android:layout_below="@id/editText_password"
android:layout_marginLeft="120dp"
android:layout_marginTop="20dp"
android:ems="10"
android:hint="请再次输入密码"
android:inputType="textPassword"
android:textSize="30dp" />
<TextView
android:id="@+id/textView_user"
android:layout_width="wrap_content"
android:layout_height="60dp"
android:layout_below="@id/imageView1"
android:layout_marginLeft="10dp"
android:layout_marginTop="20dp"
android:gravity="center"
android:text="学 号:"
android:textColor="@color/darkorange"
android:textSize="30dp" />
<TextView
android:id="@+id/textView_name"
android:layout_width="wrap_content"
android:layout_height="60dp"
android:layout_below="@id/textView_user"
android:layout_marginLeft="10dp"
android:layout_marginTop="20dp"
android:gravity="center"
android:text="姓 名:"
android:textColor="@color/darkorange"
android:textSize="30dp" />
<TextView
android:id="@+id/textView_password"
android:layout_width="wrap_content"
android:layout_height="60dp"
android:layout_below="@id/textView_name"
android:layout_marginLeft="10dp"
android:layout_marginTop="20dp"
android:gravity="center"
android:text="密 码:"
android:textColor="@color/darkorange"
android:textSize="30dp" />
<ImageView
android:id="@+id/imageView1"
android:layout_width="1000dp"
android:layout_height="200dp"
android:layout_below="@id/button_return"
app:srcCompat="@drawable/picture1" />
<Button
android:id="@+id/button_return"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginLeft="5dp"
android:layout_marginTop="5dp"
android:background="@drawable/button_full_circle_shape"
android:text="←"
android:textColor="@color/whitesmoke"
android:textSize="25dp" />
</RelativeLayout>
12.return_books_page.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Return_books_Page"
android:background="@color/lavenderblush">
<ListView
android:id="@+id/listView_return"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/textView_return"
android:layout_marginStart="5dp"
android:layout_marginTop="5dp"
android:layout_marginEnd="5dp" />
<TextView
android:id="@+id/textView_return"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginTop="5dp"
android:layout_below="@id/listView_borrow"
android:textSize="30dp"
android:background="@drawable/text_background"
android:textColor="@color/orange"
android:text="当前已还:" />
<TextView
android:id="@+id/textView_borrow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginTop="5dp"
android:layout_below="@id/button_return"
android:textSize="30dp"
android:background="@drawable/text_background"
android:textColor="@color/orange"
android:text="当前未还:" />
<ListView
android:id="@+id/listView_borrow"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/textView_borrow"
android:layout_marginStart="5dp"
android:layout_marginTop="5dp"
android:layout_marginEnd="5dp"
android:layout_marginBottom="5dp" />
<Button
android:id="@+id/button_refresh"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginStart="5dp"
android:layout_marginTop="5dp"
android:layout_marginEnd="5dp"
android:layout_marginRight="5dp"
android:layout_marginBottom="5dp"
android:background="@drawable/button_circle_shape"
android:text="刷新"
android:textColor="@color/whitesmoke"
android:textSize="25dp" />
<Button
android:id="@+id/button_return"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginLeft="5dp"
android:layout_marginTop="5dp"
android:background="@drawable/button_full_circle_shape"
android:text="←"
android:textColor="@color/whitesmoke"
android:textSize="25dp" />
</RelativeLayout>
13.study_page.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/lavenderblush"
tools:context=".Study_Page">
<RadioGroup
android:id="@+id/RadioGroup"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/datapicker"
android:layout_toRightOf="@id/study_time"
android:layout_marginLeft="20dp">
<RadioButton
android:id="@+id/radioButton_morning"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="30dp"
android:textColor="@color/steelblue"
android:text="上午" />
<RadioButton
android:id="@+id/radioButton_afternoon"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="30dp"
android:textColor="@color/steelblue"
android:text="下午" />
</RadioGroup>
<TextView
android:id="@+id/study_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/datapicker"
android:layout_marginLeft="30dp"
android:text="自习时间:"
android:textColor="@color/steelblue"
android:textSize="30dp" />
<Button
android:id="@+id/button_confirm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/datapicker"
android:layout_marginLeft="150dp"
android:layout_marginTop="100dp"
android:background="@drawable/button_circle_shape"
android:text="确 认"
android:textColor="@color/whitesmoke"
android:textSize="30dp" />
<DatePicker
android:id="@+id/datapicker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/button_return"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp" />
<Button
android:id="@+id/button_return"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginLeft="5dp"
android:layout_marginTop="5dp"
android:background="@drawable/button_full_circle_shape"
android:text="←"
android:textColor="@color/whitesmoke"
android:textSize="25dp" />
</RelativeLayout>
14.welcome_page.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Welcome_Page"
android:background="@color/lavenderblush"
>
<ImageView
android:id="@+id/imageView0"
android:layout_width="wrap_content"
android:layout_height="200dp"
android:layout_marginTop="100dp"
app:srcCompat="@drawable/picture0" />
</RelativeLayout>
三、drawable文件xml
1.button_circle_shape.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
android:shape="rectangle">
<!-- 填充的颜色 -->
<solid android:color="@color/royalblue" />
<!-- android:radius 弧形的半径 -->
<!-- 设置按钮的四个角为弧形 -->
<corners
android:radius="20dp" />
<!--也可单独设置-->
<!-- <corners -->
<!-- android:topLeftRadius="10dp"-->
<!-- android:topRightRadius="10dp"-->
<!-- android:bottomRightRadius="10dp"-->
<!-- android:bottomLeftRadius="10dp"-->
<!-- /> -->
**设置文字padding**
<!-- padding:Button里面的文字与Button边界的间隔 -->
<padding
android:left="20dp"
android:top="10dp"
android:right="20dp"
android:bottom="10dp"
/>
<stroke android:width="2.5dp"
android:color="@color/greenyellow"/>
</shape>
2.button_full_circle_shape.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<solid
android:color="@color/royalblue"/>
<corners
android:radius="5000dp"/>
<stroke android:width="2.5dp"
android:color="@color/greenyellow"/>
</shape>
3.button_rectangle.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
android:shape="rectangle">
<!-- 填充的颜色 -->
<solid android:color="@color/lightcyan" />
<!-- android:radius 弧形的半径 -->
<!-- 设置按钮的四个角为弧形 -->
<!-- <corners-->
<!-- android:radius="20dp" />-->
<!--也可单独设置-->
<!-- <corners -->
<!-- android:topLeftRadius="10dp"-->
<!-- android:topRightRadius="10dp"-->
<!-- android:bottomRightRadius="10dp"-->
<!-- android:bottomLeftRadius="10dp"-->
<!-- /> -->
**设置文字padding**
<!-- padding:Button里面的文字与Button边界的间隔 -->
<!-- <padding-->
<!-- android:left="20dp"-->
<!-- android:top="10dp"-->
<!-- android:right="20dp"-->
<!-- android:bottom="10dp"-->
<!-- />-->
<stroke android:width="2.5dp"
android:color="@color/violet"/>
</shape>
4.text_background.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
android:shape="rectangle">
<solid android:color="#efefef"/>
<!-- <corners android:radius="5dp"/>-->
<stroke
android:width="2dp"
android:color="@color/green"/>
</shape>
5.text_background1.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
android:shape="rectangle">
<solid android:color="@color/lightgray"/>
<!-- <corners android:radius="5dp"/>-->
<stroke
android:width="2dp"
android:color="@color/salmon"/>
</shape>
四、values文件xml
1.colors.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="purple_200">#FFBB86FC</color>
<color name="purple_500">#FF6200EE</color>
<color name="purple_700">#FF3700B3</color>
<color name="teal_200">#FF03DAC5</color>
<color name="teal_700">#FF018786</color>
<color name="black">#FF000000</color>
<color name="white">#FFFFFF</color><!--白色 -->
<color name="ivory">#FFFFF0</color><!--象牙色 -->
<color name="lightyellow">#FFFFE0</color><!--亮黄色 -->
<color name="yellow">#FFFF00</color><!--黄色 -->
<color name="snow">#FFFAFA</color><!--雪白色 -->
<color name="floralwhite">#FFFAF0</color><!--花白色 -->
<color name="lemonchiffon">#FFFACD</color><!--柠檬绸色 -->
<color name="cornsilk">#FFF8DC</color><!--米绸色 -->
<color name="seashell">#FFF5EE</color><!--海贝色 -->
<color name="lavenderblush">#FFF0F5</color><!--淡紫红 -->
<color name="papayawhip">#FFEFD5</color><!--番木色 -->
<color name="blanchedalmond">#FFEBCD</color><!--白杏色 -->
<color name="mistyrose">#FFE4E1</color><!--浅玫瑰色 -->
<color name="bisque">#FFE4C4</color><!--桔黄色 -->
<color name="moccasin">#FFE4B5</color><!--鹿皮色 -->
<color name="navajowhite">#FFDEAD</color><!--纳瓦白 -->
<color name="peachpuff">#FFDAB9</color><!--桃色 -->
<color name="gold">#FFD700</color><!--金色 -->
<color name="pink">#FFC0CB</color><!--粉红色 -->
<color name="lightpink">#FFB6C1</color><!--亮粉红色 -->
<color name="orange">#FFA500</color><!--橙色 -->
<color name="lightsalmon">#FFA07A</color><!--亮肉色 -->
<color name="darkorange">#FF8C00</color><!--暗桔黄色 -->
<color name="coral">#FF7F50</color><!--珊瑚色 -->
<color name="hotpink">#FF69B4</color><!--热粉红色 -->
<color name="tomato">#FF6347</color><!--西红柿色 -->
<color name="orangered">#FF4500</color><!--红橙色 -->
<color name="deeppink">#FF1493</color><!--深粉红色 -->
<color name="fuchsia">#FF00FF</color><!--紫红色 -->
<color name="magenta">#FF00FF</color><!--红紫色 -->
<color name="red">#FF0000</color><!--红色 -->
<color name="oldlace">#FDF5E6</color><!--老花色 -->
<color name="lightgoldenrodyellow">#FAFAD2</color><!--亮金黄色 -->
<color name="linen">#FAF0E6</color><!--亚麻色 -->
<color name="antiquewhite">#FAEBD7</color><!--古董白 -->
<color name="salmon">#FA8072</color><!--鲜肉色 -->
<color name="ghostwhite">#F8F8FF</color><!--幽灵白 -->
<color name="mintcream">#F5FFFA</color><!--薄荷色 -->
<color name="whitesmoke">#F5F5F5</color><!--烟白色 -->
<color name="beige">#F5F5DC</color><!--米色 -->
<color name="wheat">#F5DEB3</color><!--浅黄色 -->
<color name="sandybrown">#F4A460</color><!--沙褐色 -->
<color name="azure">#F0FFFF</color><!--天蓝色 -->
<color name="honeydew">#F0FFF0</color><!--蜜色 -->
<color name="aliceblue">#F0F8FF</color><!--艾利斯兰 -->
<color name="khaki">#F0E68C</color><!--黄褐色 -->
<color name="lightcoral">#F08080</color><!--亮珊瑚色 -->
<color name="palegoldenrod">#EEE8AA</color><!--苍麒麟色 -->
<color name="violet">#EE82EE</color><!--紫罗兰色 -->
<color name="darksalmon">#E9967A</color><!--暗肉色 -->
<color name="lavender">#E6E6FA</color><!--淡紫色 -->
<color name="lightcyan">#E0FFFF</color><!--亮青色 -->
<color name="burlywood">#DEB887</color><!--实木色 -->
<color name="plum">#DDA0DD</color><!--洋李色 -->
<color name="gainsboro">#DCDCDC</color><!--淡灰色 -->
<color name="crimson">#DC143C</color><!--暗深红色 -->
<color name="palevioletred">#DB7093</color><!--苍紫罗兰色-->
<color name="goldenrod">#DAA520</color><!--金麒麟色 -->
<color name="orchid">#DA70D6</color><!--淡紫色 -->
<color name="thistle">#D8BFD8</color><!--蓟色 -->
<color name="lightgray">#D3D3D3</color><!--亮灰色 -->
<color name="lightgrey">#D3D3D3</color><!--亮灰色 -->
<color name="tan">#D2B48C</color><!--茶色 -->
<color name="chocolate">#D2691E</color><!--巧可力色 -->
<color name="peru">#CD853F</color><!--秘鲁色 -->
<color name="indianred">#CD5C5C</color><!--印第安红 -->
<color name="mediumvioletred">#C71585</color><!--中紫罗兰色 -->
<color name="silver">#C0C0C0</color><!--银色 -->
<color name="darkkhaki">#BDB76B</color><!--暗黄褐色 -->
<color name="rosybrown">#BC8F8F</color><!--褐玫瑰红 -->
<color name="mediumorchid">#BA55D3</color><!--中粉紫色 -->
<color name="darkgoldenrod">#B8860B</color><!--暗金黄色 -->
<color name="firebrick">#B22222</color><!--火砖色 -->
<color name="powderblue">#B0E0E6</color><!--粉蓝色 -->
<color name="lightsteelblue">#B0C4DE</color><!--亮钢兰色-->
<color name="paleturquoise">#AFEEEE</color><!--苍宝石绿 -->
<color name="greenyellow">#ADFF2F</color><!--黄绿色 -->
<color name="lightblue">#ADD8E6</color><!--亮蓝色 -->
<color name="darkgray">#A9A9A9</color><!--暗灰色 -->
<color name="darkgrey">#A9A9A9</color><!--暗灰色 -->
<color name="brown">#A52A2A</color><!--褐色 -->
<color name="sienna">#A0522D</color><!--赭色 -->
<color name="darkorchid">#9932CC</color><!--暗紫色 -->
<color name="palegreen">#98FB98</color><!--苍绿色 -->
<color name="darkviolet">#9400D3</color><!--暗紫罗兰色 -->
<color name="mediumpurple">#9370DB</color><!--中紫色 -->
<color name="lightgreen">#90EE90</color><!--亮绿色 -->
<color name="darkseagreen">#8FBC8F</color><!--暗海兰色 -->
<color name="saddlebrown">#8B4513</color><!--重褐色 -->
<color name="darkmagenta">#8B008B</color><!--暗洋红 -->
<color name="darkred">#8B0000</color><!--暗红色 -->
<color name="blueviolet">#8A2BE2</color><!--紫罗兰蓝色 -->
<color name="lightskyblue">#87CEFA</color><!--亮天蓝色 -->
<color name="skyblue">#87CEEB</color><!--天蓝色 -->
<color name="gray">#808080</color><!--灰色 -->
<color name="grey">#808080</color><!--灰色 -->
<color name="olive">#808000</color><!--橄榄色 -->
<color name="purple">#800080</color><!--紫色 -->
<color name="maroon">#800000</color><!--粟色 -->
<color name="aquamarine">#7FFFD4</color><!--碧绿色 -->
<color name="chartreuse">#7FFF00</color><!--黄绿色 -->
<color name="lawngreen">#7CFC00</color><!--草绿色 -->
<color name="mediumslateblue">#7B68EE</color><!--中暗蓝色-->
<color name="lightslategray">#778899</color><!--亮蓝灰 -->
<color name="lightslategrey">#778899</color><!--亮蓝灰 -->
<color name="slategray">#708090</color><!--灰石色 -->
<color name="slategrey">#708090</color><!--灰石色 -->
<color name="olivedrab">#6B8E23</color><!--深绿褐色 -->
<color name="slateblue">#6A5ACD</color><!--石蓝色 -->
<color name="dimgray">#696969</color><!--暗灰色 -->
<color name="dimgrey">#696969</color><!--暗灰色 -->
<color name="mediumaquamarine">#66CDAA</color><!--中绿色-->
<color name="cornflowerblue">#6495ED</color><!--菊兰色 -->
<color name="cadetblue">#5F9EA0</color><!--军兰色 -->
<color name="darkolivegreen">#556B2F</color><!--暗橄榄绿 -->
<color name="indigo">#4B0082</color><!--靛青色 -->
<color name="mediumturquoise">#48D1CC</color><!--中绿宝石-->
<color name="darkslateblue">#483D8B</color><!--暗灰蓝色 -->
<color name="steelblue">#4682B4</color><!--钢兰色 -->
<color name="royalblue">#4169E1</color><!--皇家蓝 ->
<color name="turquoise">#40E0D0</color><!-->
<color name="mediumseagreen">#3CB371</color><!--中海蓝 -->
<color name="limegreen">#32CD32</color><!--橙绿色 -->
<color name="darkslategray">#2F4F4F</color><!--暗瓦灰色 -->
<color name="darkslategrey">#2F4F4F</color><!--暗瓦灰色 -->
<color name="seagreen">#2E8B57</color><!--海绿色 -->
<color name="forestgreen">#228B22</color><!--森林绿 -->
<color name="lightseagreen">#20B2AA</color><!--亮海蓝色 -->
<color name="dodgerblue">#1E90FF</color><!--闪兰色 -->
<color name="midnightblue">#191970</color><!--中灰兰色 -->
<color name="aqua">#00FFFF</color><!--浅绿色 -->
<color name="cyan">#00FFFF</color><!--青色 -->
<color name="springgreen">#00FF7F</color><!--春绿色 -->
<color name="lime">#00FF00</color><!--酸橙色 -->
<color name="mediumspringgreen">#00FA9A</color><!--中春绿色 -->
<color name="darkturquoise">#00CED1</color><!--暗宝石绿 -->
<color name="deepskyblue">#00BFFF</color><!--深天蓝色 -->
<color name="darkcyan">#008B8B</color><!--暗青色 -->
<color name="teal">#008080</color><!--水鸭色 -->
<color name="green">#008000</color><!--绿色 -->
<color name="darkgreen">#006400</color><!--暗绿色 -->
<color name="blue">#0000FF</color><!--蓝色 -->
<color name="mediumblue">#0000CD</color><!--中兰色 -->
<color name="darkblue">#00008B</color><!--暗蓝色 -->
<color name="navy">#000080</color><!--海军色 -->
</resources>
2.strings.xml
<resources>
<string name="app_name">My Application</string>
<string-array name="search_pattern">
<item>书名</item>
<item>责任者</item>
<item>出版信息</item>
</string-array>
</resources>