欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

植物录用APP

程序员文章站 2022-03-11 15:41:56
...

开发一个录入并展示____君迁子________植物信息的APP,基本功能如下:

1. 需要录入的基本信息:中文名、经济价值(入药、观赏、可食、工业材料、未发现),录入人姓名,录入人学号,录入时间;

2. 自行在百度(百度百科)或者必应中搜索该植物信息,将对应的信息录入,然后以某种格式保存在文件或数据库里;

3. 录入完毕后将该植物的录入的信息展示在另一个界面中。

一、Android项目

植物录用APP

二、自己新建的、修改的、变化了的文件的内容

1. 文件名:activity_main.xml,界面布局文件

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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:background="@mipmap/shi"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <TextView
    android:id="@+id/t_10"
    android:layout_width="149dp"
    android:layout_height="45dp"
    android:layout_marginStart="8dp"
    android:layout_marginTop="8dp"
    android:layout_marginEnd="8dp"
    android:layout_marginBottom="8dp"
    android:text="录入人信息"
    android:textSize="24sp"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintHorizontal_bias="0.617"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.564" />

    <TextView
        android:id="@+id/t_11"
        android:layout_width="149dp"
        android:layout_height="45dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginBottom="8dp"
        android:text="植  物  信  息"
        android:textSize="24sp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.617"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.055" />

    <TextView
        android:id="@+id/t_6"
        android:layout_width="90dp"
        android:layout_height="40dp"
        android:text="录入人学号"
        android:textSize="18sp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.305"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.743" />

    <TextView
        android:id="@+id/t_4"
        android:layout_width="84dp"
        android:layout_height="40dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginBottom="8dp"
        android:text="经济价值"
        android:textSize="18sp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.289"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.48" />

    <TextView
        android:id="@+id/t_5"
        android:layout_width="90dp"
        android:layout_height="40dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginBottom="8dp"
        android:text="录入人姓名"
        android:textSize="18sp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.295"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.665" />

    <TextView
        android:id="@+id/t_3"
        android:layout_width="84dp"
        android:layout_height="40dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginBottom="8dp"
        android:text="分     布"
        android:textSize="18sp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.289"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.376" />

    <Button
        android:id="@+id/btn_date"
        android:layout_width="102dp"
        android:layout_height="46dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginBottom="8dp"
        android:text="录入时间"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.279"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.841" />

    <TextView
        android:id="@+id/t_2"
        android:layout_width="84dp"
        android:layout_height="40dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginBottom="8dp"
        android:text="特     征"
        android:textSize="18sp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.289"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.282" />

    <TextView
        android:id="@+id/e_6"
        android:layout_width="200dp"
        android:layout_height="37dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginBottom="8dp"
        android:ems="10"
        android:inputType="textPersonName"
        android:textSize="20sp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="1.0"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.843" />

    <EditText
        android:id="@+id/e_5"
        android:layout_width="216dp"
        android:layout_height="48dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginBottom="8dp"
        android:ems="10"
        android:inputType="textPersonName"
        android:textSize="20sp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="1.0"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.746" />

    <EditText
        android:id="@+id/e_2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginBottom="8dp"
        android:ems="10"
        android:inputType="textPersonName"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="1.0"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.261" />

    <EditText
        android:id="@+id/e_3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginBottom="8dp"
        android:ems="10"
        android:inputType="textPersonName"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="1.0"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.358" />

    <EditText
        android:id="@+id/e_1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginBottom="8dp"
        android:ems="10"
        android:inputType="textPersonName"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="1.0"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.162" />


    <TextView
        android:id="@+id/t_1"
        android:layout_width="84dp"
        android:layout_height="40dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginBottom="8dp"
        android:text="中  文  名"
        android:textSize="18sp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.289"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.185" />

    <Button
        android:id="@+id/btn_2"
        android:layout_width="239dp"
        android:layout_height="48dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginBottom="8dp"
        android:text="开始录入"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.673"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.965" />

    <TextView
        android:id="@+id/textView5"
        android:layout_width="58dp"
        android:layout_height="712dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginBottom="8dp"
        android:lineSpacingExtra="30sp"
        android:text="           植  物  信 息 录 入 "
        android:textAllCaps="false"
        android:textSize="36sp"
        android:textStyle="bold"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.035"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.333" />

    <Spinner
        android:id="@+id/spinner_1"
        android:layout_width="206dp"
        android:layout_height="39dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginBottom="8dp"
        android:entries="@array/use"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="1.0"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.461" />

    <EditText
        android:id="@+id/e_4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginBottom="8dp"
        android:ems="10"
        android:inputType="textPersonName"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="1.0"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.652" />


</androidx.constraintlayout.widget.ConstraintLayout>
 

2. 文件名:activity_main.xml,界面布局图片

植物录用APP

3 文件名:sencond_activity_main.xml,界面布局文件

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:orientation="vertical"
    android:background="@mipmap/shi"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <EditText
        android:id="@+id/text_1"
        android:layout_width="183dp"
        android:layout_height="62dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginBottom="8dp"
        android:hint="输入植物名"
        android:textSize="20sp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.787"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.196" />

    <TextView
        android:id="@+id/text_6"
        android:layout_width="184dp"
        android:layout_height="40dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginBottom="8dp"
        android:textSize="20sp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.824"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.823" />

    <TextView
        android:id="@+id/text_5"
        android:layout_width="184dp"
        android:layout_height="40dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginBottom="8dp"
        android:textSize="20sp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.824"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.555" />

    <TextView
        android:id="@+id/text_7"
        android:layout_width="184dp"
        android:layout_height="40dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginBottom="8dp"
        android:textSize="20sp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.824"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.73" />

    <TextView
        android:id="@+id/text_4"
        android:layout_width="184dp"
        android:layout_height="40dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginBottom="8dp"
        android:textSize="20sp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.824"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.637" />

    <TextView
        android:id="@+id/text_2"
        android:layout_width="184dp"
        android:layout_height="40dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginBottom="8dp"
        android:textSize="20sp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.824"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.383" />

    <TextView
        android:id="@+id/t_4"
        android:layout_width="92dp"
        android:layout_height="39dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginBottom="8dp"
        android:text="经 济 价 值"
        android:textSize="18sp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.062"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.554" />

    <TextView
        android:id="@+id/t_6"
        android:layout_width="90dp"
        android:layout_height="40dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginBottom="8dp"
        android:text="录 入 时 间"
        android:textSize="18sp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.062"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.823" />

    <TextView
        android:id="@+id/t_7"
        android:layout_width="90dp"
        android:layout_height="40dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginBottom="8dp"
        android:text="录入人学号"
        android:textSize="18sp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.062"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.73" />

    <TextView
        android:id="@+id/t_5"
        android:layout_width="90dp"
        android:layout_height="40dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginBottom="8dp"
        android:text="录入人姓名"
        android:textSize="18sp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.062"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.637" />

    <TextView
        android:id="@+id/t_3"
        android:layout_width="96dp"
        android:layout_height="40dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginBottom="8dp"
        android:text=" 分          布"
        android:textSize="18sp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.05"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.472" />

    <TextView
        android:id="@+id/t_2"
        android:layout_width="98dp"
        android:layout_height="41dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginBottom="8dp"
        android:text=" 特         征"
        android:textSize="18sp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.043"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.385" />

    <TextView
        android:id="@+id/t_1"
        android:layout_width="99dp"
        android:layout_height="44dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginBottom="8dp"
        android:text="中   文   名"
        android:textSize="18sp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.041"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.217" />

    <TextView
        android:id="@+id/textView5"
        android:layout_width="201dp"
        android:layout_height="50dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginBottom="8dp"
        android:text="植物信息查询"
        android:textSize="30sp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.081" />
    <TextView
        android:id="@+id/text_3"
        android:layout_width="184dp"
        android:layout_height="40dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginBottom="8dp"
        android:textSize="20sp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.824"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.472" />

    <Button
        android:id="@+id/button3"
        android:layout_width="123dp"
        android:layout_height="49dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginBottom="8dp"
        android:text="点击删除"
        android:textSize="18sp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.863"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.905" />

    <Button
        android:id="@+id/button2"
        android:layout_width="239dp"
        android:layout_height="48dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginBottom="8dp"
        android:text="返回录用界面"
        android:textSize="18sp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.378"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.988" />

    <Button
        android:id="@+id/button"
        android:layout_width="123dp"
        android:layout_height="49dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginBottom="8dp"
        android:text="点击查询"
        android:textSize="18sp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.863"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.285" />
</androidx.constraintlayout.widget.ConstraintLayout>


 

4. 文件名:sencond_activity_main.xml,界面布局图片

植物录用APP

5. 文件名:MainActivity.java

package com.example.helloworld;

import android.app.Activity;
import android.app.DatePickerDialog;
import android.content.ContentValues;
import android.content.Intent;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

import java.util.Calendar;
import java.util.Locale;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {
    Button btn_date;
    Button btn_2;
    EditText e_1;
    EditText e_2;
    EditText e_3;
    EditText e_4;
    EditText e_5;
    Spinner spinner_1;
    TextView e_date;
    Calendar calendar= Calendar.getInstance(Locale.CHINA);
    plant_database helper;
    SQLiteDatabase db;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        e_date=(TextView)findViewById(R.id.e_6);
        findViewById(R.id.btn_2).setOnClickListener(this);
        findViewById(R.id.btn_date).setOnClickListener(this);
        helper= new plant_database(this,"plant.db",null,1);
        db=helper.getWritableDatabase();
        e_1=(EditText) findViewById(R.id.e_1);
        e_2=(EditText) findViewById(R.id.e_2);
        e_3=(EditText) findViewById(R.id.e_3);
        e_4=(EditText) findViewById(R.id.e_4);
        e_5=(EditText) findViewById(R.id.e_5);
        spinner_1=(Spinner)findViewById(R.id.spinner_1);

    }

    public static void showDatePickerDialog(Activity activity, int themeResId, final TextView tv, Calendar calendar) {
        new DatePickerDialog(activity, themeResId, new DatePickerDialog.OnDateSetListener() {
            @Override
            public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
                tv.setText( year + "年" + (monthOfYear + 1) + "月" + dayOfMonth + "日");
            }
        }
                , calendar.get(Calendar.YEAR)
                , calendar.get(Calendar.MONTH)
                , calendar.get(Calendar.DAY_OF_MONTH)).show();
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.btn_date:
                showDatePickerDialog(this,3,e_date,calendar);
                break;
            case R.id.btn_2:

                String t1=e_1.getText().toString();
                String t2=e_2.getText().toString();
                String t3=e_3.getText().toString();
                String t4=spinner_1.getSelectedItem().toString();
                String t5=e_4.getText().toString();
                String t6=e_date.getText().toString();
                String t7=e_5.getText().toString();
                insert_1(t1,t2,t3,t4,t5,t6,t7);
                Toast.makeText(MainActivity.this,"录用成功",Toast.LENGTH_SHORT).show();
                Intent intent=new Intent(MainActivity.this,SencondAcitivity.class);
                startActivity(intent);
                break;
        }
    }
    public void insert_1(String v,String v1,String v2,String v3,String v4,String v5,String v6)
    {
        ContentValues values=new ContentValues();
        values.put("name",v);
        values.put("tz",v1);
        values.put("fb",v2);
        values.put("jz",v3);
        values.put("usename",v4);
        values.put("datetime",v5);
        values.put("userid",v6);
        db.insert("plant",null,values);
    }
}
 

6. 文件名:SencondAcitivity.java

package com.example.helloworld;
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.TextView;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
public class SencondAcitivity extends AppCompatActivity implements View.OnClickListener {
    TextView text_1;
    TextView text_2;
    TextView text_3;
    TextView text_4;
    TextView text_5;
    TextView text_6;
    TextView text_7;
    Button button;
    SQLiteDatabase db;
    plant_database helper;
    String vi,v1,v2,v3,v4,v5,v6;
    String t1,t2,t3,t4,t5;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.sencond_activity_main);
        findViewById(R.id.button).setOnClickListener(this);
        findViewById(R.id.button2).setOnClickListener(this);
        findViewById(R.id.button3).setOnClickListener(this);
        helper=new plant_database(this,"plant.db",null,1);
        db=helper.getWritableDatabase();
        text_1=(TextView) findViewById(R.id.text_1);
        text_2=(TextView) findViewById(R.id.text_2);
        text_3=(TextView) findViewById(R.id.text_3);
        text_4=(TextView) findViewById(R.id.text_4);
        text_5=(TextView) findViewById(R.id.text_5);
        text_6=(TextView)findViewById(R.id.text_6);
        text_7=(TextView) findViewById(R.id.text_7);
    }
    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.button:
                if (text_1.getText().toString().trim().length()!=0){
                    vi=text_1.getText().toString();
                    select_1(vi);
                    //text_1.setText(v.toString());
                    text_2.setText(v1.toString());
                    text_3.setText(v2.toString());
                    text_4.setText(v3.toString());
                    text_5.setText(v4.toString());
                    text_6.setText(v5.toString());
                    text_7.setText(v6.toString());
                }
                else{ Toast.makeText(SencondAcitivity.this,"请输入植物中文名", Toast.LENGTH_LONG).show();}
                break;
            case R.id.button3:
                helper.delete(db, vi);
                Toast.makeText(SencondAcitivity.this,"删除成功",Toast.LENGTH_SHORT).show();
                break;
            case R.id.button2:
                Intent intent = new Intent();
                intent.setClass(SencondAcitivity.this, MainActivity.class);
                SencondAcitivity.this.startActivity(intent);//启动Activity
                break;

        }
    }
    public void select_1(String n){
        Cursor cursor =db.rawQuery("select * from plant where name=?",new String[]{ n });
        if (cursor.moveToFirst()) {
            //v=cursor.getString(cursor.getColumnIndex("name"));
            v1=cursor.getString(cursor.getColumnIndex("tz"));
            v2=cursor.getString(cursor.getColumnIndex("fb"));
            v3=cursor.getString(cursor.getColumnIndex("jz"));
            v4=cursor.getString(cursor.getColumnIndex("usename"));
            v5=cursor.getString(cursor.getColumnIndex("datetime"));
            v6=cursor.getString(cursor.getColumnIndex("userid"));
            cursor.close();
        }
    }
}

 

7 文件名: plant_database.java

package com.example.helloworld;
import android.content.ContentValues;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
public class plant_database extends SQLiteOpenHelper {
    public plant_database(Context context, String name, SQLiteDatabase.CursorFactory factory, int version) {
        super(context, "plant.db", factory, version);
    }
    public void onCreate(SQLiteDatabase db) {
        db.execSQL("CREATE TABLE plant(personid INTEGER PRIMARY KEY AUTOINCREMENT" +
                ",name VARCHAR(20)" +
                ",tz VARCHAR(20)," +
                "fb VARCHAR(20)" +
                ",jz VARCHAR(20)" +
                ",usename VARCHAR(20)" +
                ",datetime VARCHAR(20)" +
                ",userid VARCHAR(20))"
        );

    }
    @Override
    public void onUpgrade(SQLiteDatabase db, int i, int i1) {

    }
    public void delete(SQLiteDatabase db,String name) {
        String where = "name= ?";
        String[] whereArgs = {name + ""};
        db.delete("plant", where, whereArgs);
        db.close();
    }
    public void updata(SQLiteDatabase db, String name, String tz){
        ContentValues values=new ContentValues();
        String where = "name= ?";
        String[] whereArgs = {name + ""};
        // values.put("plantname",name);
        values.put("tezheng",tz);
        //values.put("fenbu",fb);
        //values.put("jjjz",jz);
        // values.put("username",usename);
        // values.put("userid",userid);
        //  values.put("usertime",datetime);
        db.update("plant", values,where, whereArgs);
        db.close();
    }
}
 

8 文件名: spinners.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string-array name="use">
        <item>   入   药   </item>
        <item>   观   赏   </item>
        <item>   可   食   </item>
        <item> 工 业 材 料 </item>
        <item>  未 发 现  </item>
    </string-array>
</resources>

9 文件名: AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:dist="http://schemas.android.com/apk/distribution"
    package="com.example.helloworld">
    <dist:module dist:instant="true" />
    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".SencondAcitivity"></activity>
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

三、APP的调试或运行,显示运行的结果,查看生成的文件

植物录用APP
(图一   信息录入界面)
植物录用APP
(图二   点击录入时间按钮选择时间)
植物录用APP
(图三   点击开始录入按钮跳转查询界面,提示录用成功)
植物录用APP
(图四   点击查询按钮,如果未输入植物中文名将提示)
植物录用APP
(图五   点击查询按钮,查询显示界面)
植物录用APP
(图六   点击删除按钮,提示删除成功,数据库君迁子信息被删除)
植物录用APP
(图七     数据库可视化界面)