Android记单词app(包含数据库)

打印 上一主题 下一主题

主题 1014|帖子 1014|积分 3042

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

x
一、功能与要求

实现功能:设计与开发记单词体系的,体系功能包括用户登录、用户注册、单词利用(单词的添加、查询、修改及删除)以及忘记密码等。
指标要求:通过用户登录、用户注册、单词利用、忘记密等功能的设计与开发,把握Android常用布局、控件的利用、监听器的设置以及Android数据库中SQLite数据库利用。
提交作品:项目设计报告。
二、方案设计

(一)UI布局设计

1. 登岸界面

该该界面采用LinearLayout布局,界面中包含团体界面采用线性布局布局方式,界面中包含TextView、EditText、Button等控件,布局设计如下图1所示:

图1 用户登录界面设计


2. 注册界面

该界面采用LinearLayout布局,界面中包含TextView、EditText、Button、RadioGroup、radioButton、toggleButton、checkBox、spinner等控件,布局设计如下图2所示:

图2 用户注册界面设计

3. 单词利用界面

该该界面采用LinearLayout布局,界面中包含textview、TableRow、EditText、Button、TableRow、ListView、RatingBar等控件,布局设计如下图3所示:


图3 单词利用界面设计

4. 忘记密码界面

该界面采用LinearLayout布局,界面中包含textview、EditText、Button等控件,布局设计如下图4所示:

图4 忘记密码界面

(二)业务流程图

在登录界面中,用户首先输入用户名和密码,点击“登录”按钮将用户输入的信息与数据库表中用户名密码举行匹配,如果正确,则跳转到单词利用页面,否则提示用户用户名密码有误。点击“注册按钮”跳转到注册页面,在注册页面中,通过输入注册信息,点击“注册按钮”将数据写入到数据库对应的表中,并提示用户注册乐成。
详细的流程如下图所示:

图5 登岸注册流程图


三、项目实现步调

步调1:搭建开发环境。
步调2:预备资源。
步调3:界面设计。
步调4:界面开发。
四、项目实现

(一)用户登录

界面如下图6所示:

前台核心代码如下:
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3.     xmlns:app="http://schemas.android.com/apk/res-auto"
  4.     xmlns:tools="http://schemas.android.com/tools"
  5.     android:layout_width="match_parent"
  6.     android:layout_height="match_parent"
  7.     android:orientation="vertical"
  8.     android:background="@drawable/bg"
  9.     tools:context=".MainActivity">
  10.     <LinearLayout
  11.         android:layout_width="match_parent"
  12.         android:layout_height="wrap_content"
  13.         android:layout_marginTop="500dp"
  14.         android:orientation="horizontal">
  15.         <TextView
  16.             android:id="@+id/textView"
  17.             android:layout_width="wrap_content"
  18.             android:layout_height="wrap_content"
  19.             android:layout_weight="1"
  20.             android:gravity="right"
  21.             android:text="用户名称:"
  22.             android:textColor="#000000"
  23.             android:textSize="24sp" />
  24.         <EditText
  25.             android:id="@+id/edname"
  26.             android:layout_width="wrap_content"
  27.             android:layout_height="wrap_content"
  28.             android:layout_weight="1"
  29.             android:ems="10"
  30.             android:hint="请输入用户名"
  31.             android:inputType="textPersonName" />
  32.     </LinearLayout>
  33.     <LinearLayout
  34.         android:layout_width="match_parent"
  35.         android:layout_height="wrap_content"
  36.         android:orientation="horizontal">
  37.         <TextView
  38.             android:id="@+id/textView2"
  39.             android:layout_width="wrap_content"
  40.             android:layout_height="wrap_content"
  41.             android:layout_weight="1"
  42.             android:gravity="right"
  43.             android:text="用户密码:"
  44.             android:textColor="#000000"
  45.             android:textSize="24sp" />
  46.         <EditText
  47.             android:id="@+id/edpwd"
  48.             android:layout_width="wrap_content"
  49.             android:layout_height="wrap_content"
  50.             android:layout_weight="1"
  51.             android:ems="10"
  52.             android:hint=" 请输入密码"
  53.             android:inputType="numberPassword" />
  54.     </LinearLayout>
  55.     <Button
  56.         android:id="@+id/btn_wjmm"
  57.         android:layout_width="wrap_content"
  58.         android:layout_height="wrap_content"
  59.         android:layout_gravity="right"
  60.         android:background="#00FFFFFF"
  61.         android:text="忘记密码?"
  62.         android:textColor="#000000"
  63.         android:textSize="16sp" />
  64.     <LinearLayout
  65.         android:layout_width="match_parent"
  66.         android:layout_height="match_parent"
  67.         android:orientation="horizontal">
  68.         <Button
  69.             android:id="@+id/btn_login"
  70.             android:layout_width="wrap_content"
  71.             android:layout_height="wrap_content"
  72.             android:layout_weight="1"
  73.             android:text="登录"
  74.             android:textSize="24sp" />
  75.         <Button
  76.             android:id="@+id/btn_reg"
  77.             android:layout_width="wrap_content"
  78.             android:layout_height="wrap_content"
  79.             android:layout_weight="1"
  80.             android:text="注册"
  81.             android:textSize="24sp" />
  82.     </LinearLayout>
  83. </LinearLayout>
复制代码
后台核心代码如下:
  1. package com.example.word6;
  2. import androidx.appcompat.app.AppCompatActivity;
  3. import android.annotation.SuppressLint;
  4. import android.content.Intent;
  5. import android.database.Cursor;
  6. import android.database.sqlite.SQLiteDatabase;
  7. import android.os.Bundle;
  8. import android.view.View;
  9. import android.widget.Button;
  10. import android.widget.EditText;
  11. import android.widget.Toast;
  12. public class MainActivity extends AppCompatActivity implements View.OnClickListener{
  13.     private EditText edname,edpwd;
  14.     private Button btn_login,btn_reg,btn_wjmm;
  15.     private MyDBOpenHelper myDBOpenHelper;
  16.     private SQLiteDatabase db;
  17.     @Override
  18.     protected void onCreate(Bundle savedInstanceState) {
  19.         super.onCreate(savedInstanceState);
  20.         setContentView(R.layout.activity_main);
  21.         initview();
  22.         btn_wjmm.setOnClickListener(this);
  23.         btn_reg.setOnClickListener(this);
  24.         btn_login.setOnClickListener(this);
  25.     }
  26.     @Override
  27.     public void onClick(View view) {
  28.         switch (view.getId()){
  29.             case R.id.btn_login:
  30.                 login();
  31.                 break;
  32.             case R.id.btn_reg:
  33.                 Intent intent=new Intent(MainActivity.this,RegisterActivity.class);
  34.                 startActivity(intent);
  35.                 break;
  36.             case R.id.btn_wjmm:
  37.                 Intent intent1=new Intent(MainActivity.this,UpdatePwdActivity.class);
  38.                 startActivity(intent1);
  39.                 break;
  40.         }
  41.     }
  42.     //登录
  43.     @SuppressLint("Range")
  44.     private void login() {
  45.         String name=edname.getText().toString();
  46.         String pwd=edpwd.getText().toString();
  47.         if(name.equals("")||pwd.equals("")){
  48.             Toast.makeText(MainActivity.this,"用户名或密码不能为空",Toast.LENGTH_SHORT).show();
  49.         }else {
  50.             Cursor cursor=db.query("user_info",new String[]{"username","userpwd"},null,null,null,null,null);
  51.             Boolean flag=false;
  52.             while (cursor.moveToNext()){
  53.                 if(name.equals(cursor.getString(cursor.getColumnIndex("username")))
  54.                         &&pwd.equals(cursor.getString(cursor.getColumnIndex("userpwd")))){
  55.                     flag=true;
  56.                     break;
  57.                 }
  58.             
复制代码
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
回复

使用道具 举报

0 个回复

倒序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

兜兜零元

论坛元老
这个人很懒什么都没写!
快速回复 返回顶部 返回列表