qidao123.com技术社区-IT企服评测·应用市场
标题:
Android记单词app(包含数据库)
[打印本页]
作者:
兜兜零元
时间:
2025-1-12 22:53
标题:
Android记单词app(包含数据库)
一、功能与要求
实现功能
:设计与开发记单词体系的,体系功能包括用户登录、用户注册、单词利用(单词的添加、查询、修改及删除)以及忘记密码等。
指标要求
:通过用户登录、用户注册、单词利用、忘记密等功能的设计与开发,把握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所示:
前台核心代码如下:
<?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"
android:orientation="vertical"
android:background="@drawable/bg"
tools:context=".MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="500dp"
android:orientation="horizontal">
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right"
android:text="用户名称:"
android:textColor="#000000"
android:textSize="24sp" />
<EditText
android:id="@+id/edname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:hint="请输入用户名"
android:inputType="textPersonName" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right"
android:text="用户密码:"
android:textColor="#000000"
android:textSize="24sp" />
<EditText
android:id="@+id/edpwd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:hint=" 请输入密码"
android:inputType="numberPassword" />
</LinearLayout>
<Button
android:id="@+id/btn_wjmm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:background="#00FFFFFF"
android:text="忘记密码?"
android:textColor="#000000"
android:textSize="16sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<Button
android:id="@+id/btn_login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="登录"
android:textSize="24sp" />
<Button
android:id="@+id/btn_reg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="注册"
android:textSize="24sp" />
</LinearLayout>
</LinearLayout>
复制代码
后台核心代码如下:
package com.example.word6;
import androidx.appcompat.app.AppCompatActivity;
import android.annotation.SuppressLint;
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 MainActivity extends AppCompatActivity implements View.OnClickListener{
private EditText edname,edpwd;
private Button btn_login,btn_reg,btn_wjmm;
private MyDBOpenHelper myDBOpenHelper;
private SQLiteDatabase db;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initview();
btn_wjmm.setOnClickListener(this);
btn_reg.setOnClickListener(this);
btn_login.setOnClickListener(this);
}
@Override
public void onClick(View view) {
switch (view.getId()){
case R.id.btn_login:
login();
break;
case R.id.btn_reg:
Intent intent=new Intent(MainActivity.this,RegisterActivity.class);
startActivity(intent);
break;
case R.id.btn_wjmm:
Intent intent1=new Intent(MainActivity.this,UpdatePwdActivity.class);
startActivity(intent1);
break;
}
}
//登录
@SuppressLint("Range")
private void login() {
String name=edname.getText().toString();
String pwd=edpwd.getText().toString();
if(name.equals("")||pwd.equals("")){
Toast.makeText(MainActivity.this,"用户名或密码不能为空",Toast.LENGTH_SHORT).show();
}else {
Cursor cursor=db.query("user_info",new String[]{"username","userpwd"},null,null,null,null,null);
Boolean flag=false;
while (cursor.moveToNext()){
if(name.equals(cursor.getString(cursor.getColumnIndex("username")))
&&pwd.equals(cursor.getString(cursor.getColumnIndex("userpwd")))){
flag=true;
break;
}
复制代码
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
欢迎光临 qidao123.com技术社区-IT企服评测·应用市场 (https://dis.qidao123.com/)
Powered by Discuz! X3.4