您当前的位置:首页 > 毕业设计

毕业设计- Android图书借阅管理系统

时间:2022-03-05 07:43:09 阅读数:44,603人阅读
版权声明:转载请注明出处,谢谢!
—— 这个世界,一百万人里面只有一个主角。当主角的都是能够达到极致的人。

项目介绍

用户角色分为系统管理员和借阅者

1. 系统管理员可以管理图书信息如增加图书、编辑图书、删除图书,可以管理借阅者信息如增加借阅者、编辑借阅者、删除借阅者;

2. 借阅者可以注册登录系统,浏览所有图书,借阅和归还,查看已借阅列表和已归还列表;

项目截图

实现原理

布局文件activity_main.xml:

			<?xml version="1.0" encoding="utf-8"?>
			<androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
				xmlns:app="http://schemas.android.com/apk/res-auto"
				android:id="@+id/drawerlayout"
				android:layout_width="match_parent"
				android:layout_height="match_parent">

				<androidx.coordinatorlayout.widget.CoordinatorLayout
					android:layout_width="match_parent"
					android:layout_height="match_parent">

					<com.google.android.material.appbar.AppBarLayout
						android:layout_width="match_parent"
						android:layout_height="wrap_content">

						<androidx.appcompat.widget.Toolbar
							android:id="@+id/toolbar"
							android:layout_width="match_parent"
							android:layout_height="?attr/actionBarSize"
							android:background="?attr/colorPrimary"
							app:layout_scrollFlags="scroll|enterAlways|snap"
							app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
							app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />
					</com.google.android.material.appbar.AppBarLayout>

					<TextView
						android:id="@+id/tv_empty"
						android:layout_width="match_parent"
						android:layout_height="wrap_content"
						android:layout_marginTop="40dp"
						android:gravity="center_horizontal"
						android:text="馆中暂无藏书,请登录管理员添加图书!"
						app:layout_behavior="@string/appbar_scrolling_view_behavior" />

					<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
						android:id="@+id/swipe_refrsh"
						android:layout_width="match_parent"
						android:layout_height="match_parent"
						android:visibility="gone"
						app:layout_behavior="@string/appbar_scrolling_view_behavior">

						<ListView
							android:id="@+id/list_view"
							android:layout_width="match_parent"
							android:layout_height="match_parent"
							app:layout_behavior="@string/appbar_scrolling_view_behavior" />
					</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
				</androidx.coordinatorlayout.widget.CoordinatorLayout>

				<com.google.android.material.navigation.NavigationView
					android:id="@+id/nav_view"
					android:layout_width="match_parent"
					android:layout_height="match_parent"
					android:layout_gravity="start"
					app:menu="@menu/nav_meun" />
			</androidx.drawerlayout.widget.DrawerLayout>
	  
	       public class contentActivity extends AppCompatActivity implements View.OnClickListener {
				private DrawerLayout drawerLayout;
				private SwipeRefreshLayout swipeRefrsh;
				private ListView listView;
				private Cursor cursor;
				private TextView tvEmpty;
				private long mExitTime;

				@Override
				protected void onCreate(Bundle savedInstanceState) {
					super.onCreate(savedInstanceState);
					setContentView(R.layout.activity_content);

					GridLayoutManager layoutManager = new GridLayoutManager(this, 2);
					Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
					setSupportActionBar(toolbar);
					drawerLayout = (DrawerLayout) findViewById(R.id.drawerlayout);
					NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
					View headerLayout = navigationView.inflateHeaderView(R.layout.nav_head);
					SharedPreferences sp = getSharedPreferences("data", MODE_PRIVATE);
					String username = sp.getString("users", "");
					TextView tvName = headerLayout.findViewById(R.id.tv_name);
					tvName.setText("欢迎您:" + username);
					ActionBar actionBar = getSupportActionBar();
					if (actionBar != null) {
						actionBar.setDisplayHomeAsUpEnabled(true);
						actionBar.setHomeAsUpIndicator(R.mipmap.ic_menu);
					}
					//侧滑菜单栏的选项
					navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
						@Override
						public boolean onNavigationItemSelected(@NonNull MenuItem item) {
							switch (item.getItemId()) {
								case R.id.exit:
									startActivity(new Intent(contentActivity.this, MainActivity.class));
									finish();
									break;
								case R.id.jieyue:
									//跳转到个人借书的页面
									Intent intent = new Intent(contentActivity.this, person_borrow.class);
									startActivity(intent);
									break;
								case R.id.guihuan:
									//跳转到个人借书的页面
									Intent intent0 = new Intent(contentActivity.this, person_pay.class);
									startActivity(intent0);
									break;
								default:
							}
							drawerLayout.closeDrawers();//将滑动菜单关闭
							return true;
						}
					});
					insert();//插入数据往借书表中
					listView = (ListView) findViewById(R.id.list_view);
					databaseHelp help = new databaseHelp(getApplicationContext());

					cursor = help.querybookinfo();
					String from[] = {"_id", "bookname", "author"};
					int to[] = {R.id.book_bid, R.id.book_name, R.id.book_author};
					SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, R.layout.book_item, cursor, from, to);
					listView.setAdapter(adapter);

					swipeRefrsh = findViewById(R.id.swipe_refrsh);
					tvEmpty = findViewById(R.id.tv_empty);
					if (cursor.getCount() > 0) {
						swipeRefrsh.setVisibility(View.VISIBLE);
						tvEmpty.setVisibility(View.GONE);
					} else {
						swipeRefrsh.setVisibility(View.GONE);
						tvEmpty.setVisibility(View.VISIBLE);
					}
				}

				private void insert() {
					listView = (ListView) findViewById(R.id.list_view);
					listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
						@Override
						public void onItemClick(AdapterView<?> adapterView, View view, final int position, long l) {
							setTitle("馆藏书籍列表");
							Intent intent = new Intent(contentActivity.this, borrowActivity.class);
							Bundle bundle = new Bundle();
							bundle.putInt("id", cursor.getInt(cursor.getColumnIndex("_id")));
							intent.putExtras(bundle);
							startActivity(intent);
						}
					});
				}

				//toolbar的菜单栏的选项
				@Override
				public boolean onOptionsItemSelected(MenuItem item) {
					switch (item.getItemId()) {
						case android.R.id.home:
							drawerLayout.openDrawer(GravityCompat.START);
							break;
						default:
					}
					return true;
				}

				@Override
				public void onClick(View v) {
				}

				@Override
				public boolean onCreateOptionsMenu(Menu menu) {
					getMenuInflater().inflate(R.menu.toolbar, menu);
					return true;
				}

				@Override
				public void onBackPressed() {
					exit();
				}

				public void exit() {
					if ((System.currentTimeMillis() - mExitTime) > 2000) {
						Toast.makeText(contentActivity.this, "再按一次退出程序", Toast.LENGTH_SHORT).show();
						mExitTime = System.currentTimeMillis();
					} else {
						finish();
					}
				}

			}
	  

购买套餐

权益 套餐A 套餐B
完整代码
远程调试 不支持
代码答疑 不支持
价 格 ¥180 ¥330

------转载请注明出处,感谢您对原创作者的支持------

有偿提供技术支持、Bug修复、项目外包、毕业设计、大小作业

Android学习小站

Q Q:1095817610

微信:jx-helu

邮箱:1095817610@qq.com

添加请备注"Android学习小站"