Android开发:使用AndroidStudio开发记单词APP(带数据库)

一、功能与要求

实现功能:设计与开发记单词系统的四个界面,分别是用户登录、用户注册、单词操作以及忘记密码。
指标要求:通过用户登录、用户注册、单词操作、忘记密码掌握界面设计的基础,其中包括界面布局、常用控件、事件处理等相关内容,通过所学内容设计与开发的界面要求简洁、美观。

二、方案设计

(一)用户登录界面

该界面采用LinearLayout布局,界面中包含整体界面采用线性布局布局方式,界面中包含TextView、EditText、Button等控件,布局设计如下图1所示:
在这里插入图片描述
图1 用户登录界面设计

(二) 用户注册界面

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

图2 用户注册界面设计

(三)单词操作界面

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

在这里插入图片描述

图3 单词操作界面设计

(四)忘记密码界面

该界面采用…布局,界面中包含textview、EditText、Button等控件,布局设计如下图4所示:
在这里插入图片描述

图4 忘记密码界面

三、项目实现步骤

步骤1:搭建开发环境。

1.创建项目ReadWord

在这里插入图片描述

步骤2:准备资源。

2.1 准备好项目所需要的图片
在这里插入图片描述

2.2 将图片资源放入到项目的mipmap文件下
在这里插入图片描述

步骤3:UI设计与开发。

3.1 使用相对布局等管理器来实现界面的布局
在这里插入图片描述

步骤4:编写程序实现业务逻辑。

4.1使用简单的控件和相对布局来实现界面

四、项目实现

(一)用户登录界面

界面如下图5所示:
在这里插入图片描述
图5 用户登录界面

布局代码如下:

<?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="@mipmap/bg"
    tools:context=".Activity.MainActivity">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="50dp"
        android:layout_marginTop="440dp"
        android:layout_marginRight="50dp"
        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:textSize="22sp" />

        <EditText
            android:id="@+id/edit_user"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:textSize="22sp"
            android:hint="请输入用户名"
            android:inputType="textPersonName" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="50dp"
        android:layout_marginRight="50dp"
        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:textSize="22sp" />

        <EditText
            android:id="@+id/edit_pwd"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:maxLines="1"
            android:textSize="22sp"
            android:inputType="textPassword"
            android:hint="输入六位密码" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="35dp"
        android:layout_marginLeft="50dp"
        android:layout_marginRight="50dp"
        android:orientation="horizontal">

        <Button
            android:id="@+id/btn_edpwd"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:layout_marginTop="10dp"
            android:gravity="right"
            android:background="#00FFFFFF"
            android:text="忘记密码?"
            android:onClick="onClick"
            android:textColor="#6B6868"
            android:textSize="18sp" />

    </LinearLayout>
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="50dp"
            android:layout_marginRight="50dp"
            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:onClick="onClick"
                android:textSize="20sp" />
            <Button
                android:id="@+id/btn_register"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="注册"
                android:onClick="onClick"
                android:textSize="20sp" />
            <Button
                android:id="@+id/btn_select"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="查询"
                android:onClick="onClick"
                android:textSize="20sp" />
        </LinearLayout>
</LinearLayout>

(二) 用户注册界面

界面如下图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:gravity="center"
    android:background="@mipmap/bgs"
    tools:context=".Activity.RegisterActivity">

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:gravity="center"
        android:orientation="horizontal">

        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textSize="30sp"
            android:textStyle="bold"
            android:text="用户信息" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal">

        <TextView
            android:id="@+id/textView2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textSize="20sp"
            android:textStyle="bold"
            android:text="用户名称:" />

        <EditText
            android:id="@+id/editText1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:ems="10"
            android:hint="请输入用户名"
            android:inputType="textPersonName" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal">

        <TextView
            android:id="@+id/textView3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textSize="20sp"
            android:textStyle="bold"
            android:text="用户密码:" />

        <EditText
            android:id="@+id/editText2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:ems="10"
            android:hint="请输入六位数字"
            android:inputType="textPassword" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal">

        <TextView
            android:id="@+id/textView4"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textSize="20sp"
            android:textStyle="bold"
            android:text="用户实名:" />

        <EditText
            android:id="@+id/editText3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:ems="10"
            android:hint="与身份证保持一致"
            android:inputType="textPersonName" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal">

        <TextView
            android:id="@+id/textView5"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:textSize="20sp"
            android:textStyle="bold"
            android:text="性别:" />

        <RadioGroup
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="horizontal">

            <RadioButton
                android:id="@+id/radioButton"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:checked="true"
                android:text="男" />

            <RadioButton
                android:id="@+id/radioButton2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="女" />
        </RadioGroup>
    </LinearLayout>

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal">

        <TextView
            android:id="@+id/textView6"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:textSize="20sp"
            android:textStyle="bold"
            android:text="婚否:" />

        <ToggleButton
            android:id="@+id/toggleButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:textOff="未婚"
            android:textOn="已婚" />

    </LinearLayout>

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal">

        <TextView
            android:id="@+id/textView7"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:textSize="20sp"
            android:textStyle="bold"
            android:text="爱好:" />

        <CheckBox
            android:id="@+id/checkBox"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="阅读" />

        <CheckBox
            android:id="@+id/checkBox2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="游泳" />

        <CheckBox
            android:id="@+id/checkBox3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="跑步" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal">

        <TextView
            android:id="@+id/textView8"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:textSize="20sp"
            android:textStyle="bold"
            android:text="职务:" />

        <Spinner
            android:id="@+id/spinner"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:entries="@array/arrays" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal">

        <Button
            android:id="@+id/button6"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:textSize="20sp"
            android:textStyle="bold"
            android:onClick="onClick"
            android:text="取消" />

        <Button
            android:id="@+id/button7"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:textSize="20sp"
            android:textStyle="bold"
            android:onClick="onClick"
            android:text="注册" />
    </LinearLayout>

</LinearLayout>

(三) 单词操作界面

界面如下图7所示:
在这里插入图片描述
布局代码如下:

<?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="@mipmap/bgs"
    tools:context=".Activity.WordOperateActivity">
    <TableLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="center"
        >
        <TableRow
            android:layout_width="match_parent"
            android:layout_height="600dp">
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="30dp"
                android:layout_weight="1"
                android:gravity="center"
                android:orientation="vertical">
                <TextView
                    android:id="@+id/textView11"
                    android:layout_width="wrap_content"
                    android:layout_height="90dp"
                    android:layout_weight="1"
                    android:gravity="bottom"
                    android:text="单词操作界面"
                    android:textSize="23sp"
                    android:textStyle="bold" />
            </LinearLayout>
        </TableRow>
        <TableRow
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:gravity="center">
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="130dp"
                android:layout_marginTop="20dp"
                android:orientation="vertical">
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal">

                    <TextView
                        android:id="@+id/textView12"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:textSize="24sp"
                        android:gravity="center"
                        android:text="单词:"
                        android:textStyle="bold" />

                    <EditText
                        android:id="@+id/edit_danci"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:ems="10"
                        android:hint="请输入单词"
                        android:gravity="left"
                        android:inputType="textPersonName" />
                </LinearLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal">

                    <TextView
                        android:id="@+id/textView13"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:textSize="24sp"
                        android:layout_weight="1"
                        android:gravity="center"
                        android:text="解析:"
                        android:textStyle="bold" />

                    <EditText
                        android:id="@+id/edit_jiexi"
                        android:layout_width="wrap_content"
                        android:ems="10"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:gravity="left"
                        android:hint="请输入解析"
                        android:inputType="textPersonName" />
                </LinearLayout>
            </LinearLayout>
        </TableRow>

        <TableRow
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:gravity="center">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="horizontal">

                <Button
                    android:id="@+id/btn_add"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:onClick="onClick"
                    android:text="添加" />

                <Button
                    android:id="@+id/btn_sel"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:onClick="onClick"
                    android:text="查询" />

                <Button
                    android:id="@+id/btn_edit"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:onClick="onClick"
                    android:text="更新" />

                <Button
                    android:id="@+id/btn_del"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:onClick="onClick"
                    android:text="删除" />
            </LinearLayout>

        </TableRow>

        <TableRow
            android:layout_width="match_parent"
            android:layout_height="match_parent" >

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:gravity="center"
                android:orientation="vertical">

                <Button
                    android:id="@+id/btn_selAll"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="查看全部词汇" />
            </LinearLayout>

        </TableRow>

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <ListView
                android:layout_width="match_parent"
                android:layout_height="200dp"
                android:id="@+id/list_view"
                >

<!--                <TextView-->
<!--                    android:id="@+id/textword1"-->
<!--                    android:layout_width="wrap_content"-->
<!--                    android:layout_height="wrap_content"-->
<!--                    android:text="Hello"-->
<!--                    />-->
<!--                <TextView-->
<!--                    android:id="@+id/textjiexi1"-->
<!--                    android:layout_width="wrap_content"-->
<!--                    android:layout_height="wrap_content"-->
<!--                    android:text="你好"-->
<!--                    />-->

            </ListView>

        </LinearLayout>


        <TableRow
            android:layout_width="match_parent"
            android:layout_height="257dp"
            android:gravity="center">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical">

                <TextView
                    android:id="@+id/textView10"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content" />
            </LinearLayout>
        </TableRow>

        <TableRow
            android:layout_width="match_parent"
            android:layout_height="match_parent" >

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:gravity="center"
                android:orientation="horizontal">

                <RatingBar
                    android:id="@+id/ratingBar"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content" />
            </LinearLayout>

        </TableRow>


        <TableRow
            android:layout_width="match_parent"
            android:layout_height="match_parent" >

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:gravity="center"
                android:orientation="vertical">

                <Button
                    android:id="@+id/button12"
                    android:layout_width="160dp"
                    android:layout_height="wrap_content"
                    android:text="提交评论" />
            </LinearLayout>
        </TableRow>
    </TableLayout>
</LinearLayout>

(四)忘记密码界面

界面如下图8所示:
在这里插入图片描述
布局代码如下:

<?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:gravity="center"
    android:background="@mipmap/bgs"
    tools:context=".Activity.EditPwdActivity">

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:gravity="center"
        android:orientation="horizontal">

        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textSize="30sp"
            android:textStyle="bold"
            android:text="修改密码" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal">

        <TextView
            android:id="@+id/textView2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textSize="20sp"
            android:textStyle="bold"
            android:text="用户名称:" />

        <EditText
            android:id="@+id/et_user"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:ems="10"
            android:hint="请输入用户名"
            android:inputType="textPersonName" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal">

        <TextView
            android:id="@+id/textView3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textSize="20sp"
            android:textStyle="bold"
            android:text="新 密 码 :" />

        <EditText
            android:id="@+id/et_pwd"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:ems="10"
            android:hint="请输入六位数字"
            android:inputType="textPassword" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal">

        <TextView
            android:id="@+id/textView4"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textSize="20sp"
            android:textStyle="bold"
            android:text="确认密码:" />

        <EditText
            android:id="@+id/et_pwd2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:ems="10"
            android:hint="与新密码相同"
            android:inputType="textPersonName" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal">

        <Button
            android:id="@+id/btn_update"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:textSize="20sp"
            android:textStyle="bold"
            android:onClick="onClick"
            android:text="确认修改" />
    </LinearLayout>

</LinearLayout>

五、项目总结

通过该项目的设计,掌握Android项目设计开发流程,完成了一款记单词软件,UI布局界面使用了很多控件,使我掌握了TextView、EditText、Button、ratingBar、RadioGroup、radioButton、toggleButton、checkBox、spinner等控件的使用、后台使用了AlertDialog实现了注册按钮弹出对话框。此次项目设计不仅仅使对我技术上的锻炼有所提高,更多的是为我之后的学习奠定了良好的基础,但是依然有很多的不足之处需要我们继续完善和改正。

锚链是一种常见的海洋工程构件,使用锚链的目的是将船舶或构件固定在海床上。因为锚链受到海水和风浪的作用,所以需要计算锚链受力状态,以保证其安全可靠。集中质量法是一种流行的计算锚链张力的方法。下面介绍如何使用集中质量法计算锚链张力。 步骤一:确定锚链模型 首先需要确定一种合适的锚链模型,包括锚链的长度、直径和质量分布等参数。通常使用的锚链模型是基于静水力学原理的连续介质模型,即认为锚链是一种无限细的弹性体,其每一段锚链都可以看做是一个等效环节,锚链整体的力学性质可以通过累加所有相邻环节的力学性质得到。 步骤二:确定集中质量点 集中质量法将复杂的锚链模型简化为一个等效的质点,质点的质量等于整个锚链的质量,位置在锚链的重心处。重心的位置可以通过积分求解得到。 步骤三:计算锚链受力 锚链受力分为两部分,一部分是由于锚链的自重引起的张力,另一部分是由于外部作用力(例如水流和风浪)和锚位移引起的张力。锚链的自重张力可以通过集中质量点处受到的重力计算得到,外部作用力和位移引起的张力需要根据实际情况进行计算,例如可以使用海洋动力学的分析方法,结合数值模拟等手段计算。 步骤四:验证计算结果 使用集中质量法计算的锚链张力需要验证其合理性和可靠性。通常需要进行定位试验和动态试验,包括锚链拉力测试、震动测试、平衡测试等,通过实验验证计算结果的准确性。 以上是使用集中质量法计算锚链张力的步骤,需要注意的是,在实际工程中,锚链的受力状态受到许多因素的影响,因此在计算和计锚链时需要综合考虑各种因素,并做好安全保障措施。
评论 10
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

-努力搬砖的小刘-

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值