基于Android Studio 垃圾分类助手App

发布时间:2025-09-24 17:43

垃圾分类有助于资源循环利用 #生活知识# #生活习惯# #垃圾分类#

目录

一、项目演示视频

二、开发环境

三、设计与实现

1.启动页

2.注册登录

3.首页

答题页

4.搜索页

5.我的页面

6.个人信息页面

7.修改密码页面

Get项目源码

一、项目演示视频

基于Android Studio 垃圾分类助手App--原创

二、开发环境

三、设计与实现

1.启动页

1.设置延迟三秒后执行 runnable,然后跳转到登录页面。

2.初始化一个计时器 timeCount,总共执行四秒,每秒执行一次。

3.当计时器结束时,移除 runnable,即取消跳转到登录页面的操作。

图片

2.注册登录

记住密码功能:

在用户勾选“记住密码”的情况下,会将输入的用户名和密码保存到SharedPreferences中,下次打开应用时会自动填充用户名和密码,并保持勾选状态。

取消勾选时则清空保存的用户名和密码信息。

登录功能:

用户点击登录按钮后,会检查输入的用户名和密码是否为空,若为空则弹出提示。

若用户名和密码均不为空,则调用userHelper中的方法验证用户信息。

若验证通过,则会根据“记住密码”选项决定是否保存用户名和密码信息到SharedPreferences中,并跳转到主界面(MainActivity)。

若验证不通过,则弹出登录失败提示。

跳转注册页面功能:

用户点击“注册”文本时,会跳转到注册页面(RegisterActivity)。

图片

包括一个注册活动(RegisterActivity),用户可以在其中输入用户名、密码和确认密码。

如果用户名、密码或确认密码为空,应用程序会显示相应的提示消息。

如果密码与确认密码不匹配,也会有相应的提示消息。如果所有输入都有效,则会调用用户助手(UserHelper)来添加用户。

添加用户成功后,会显示注册成功消息,并将用户重定向到登录页面(LoginActivity)。

图片

3.首页

用于在主页显示视频。使用VideoView来播放视频,视频的URL是从互联网获取的。

在片段的onCreateView方法中,它获取了VideoView实例,并设置了视频的URL,然后开始播放视频。

最后,将VideoView设置为填充父布局的大小。

图片

03

答题页

简单的学习应用程序,界面包含了几个选项按钮用于回答问题。

点击按钮后会进行答案检查,显示回答是否正确,并在3秒后获取下一个问题。

同时,也可以开始答题并获取题目内容。

题目内容通过网络请求从指定的URL获取,获取到数据后会解析JSON并显示在界面上。

在整个过程中,还包括了按钮的禁用和启用功能,以及网络请求的异步处理和错误提示。

图片

4.搜索页

点击搜索按钮时根据输入的关键字发起网络请求获取数据。

getNewsData 方法中使用 OkHttpClient 发起异步网络请求,获取到响应后解析 JSON 数据,更新界面显示相关列表信息。

当网络请求失败或数据解析出错时,在 UI 线程上显示相应错误提示。整体实现了搜索关键字获取相关数据并展示的功能。

图片

<?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:layout_width="match_parent"

android:layout_height="match_parent"

android:background="#F1F1F1"

tools:context=".Fragment.SearchFragment">

<View

android:id="@+id/view2"

android:layout_width="wrap_content"

android:layout_height="50dp"

android:background="#00BCD4"

app:layout_constraintEnd_toEndOf="parent"

app:layout_constraintStart_toStartOf="parent"

app:layout_constraintTop_toTopOf="parent" />

<TextView

android:id="@+id/textView3"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="分类搜索"

android:textColor="#fff"

android:textSize="20sp"

android:textStyle="bold"

app:layout_constraintBottom_toBottomOf="@+id/view2"

app:layout_constraintEnd_toEndOf="@+id/view2"

app:layout_constraintStart_toStartOf="@+id/view2"

app:layout_constraintTop_toTopOf="parent" />

<View

android:id="@+id/view3"

android:layout_width="0dp"

android:layout_height="35dp"

android:layout_marginStart="16dp"

android:layout_marginTop="8dp"

android:layout_marginEnd="16dp"

android:background="@drawable/view"

app:layout_constraintEnd_toEndOf="parent"

app:layout_constraintHorizontal_bias="0.0"

app:layout_constraintStart_toStartOf="parent"

app:layout_constraintTop_toBottomOf="@+id/view2" />

<ImageView

android:id="@+id/img_search"

android:layout_width="20dp"

android:layout_height="0dp"

android:layout_marginRight="10dp"

android:src="@drawable/searchd"

app:layout_constraintBottom_toBottomOf="@+id/view3"

app:layout_constraintEnd_toEndOf="@+id/view3"

app:layout_constraintTop_toTopOf="@+id/view3" />

<EditText

android:id="@+id/et_search"

android:layout_width="0dp"

android:layout_height="0dp"

android:layout_marginLeft="10dp"

android:background="#fff"

android:ems="10"

android:hint="请输入名称查询"

android:inputType="textPersonName"

android:textSize="14sp"

app:layout_constraintBottom_toBottomOf="@+id/view3"

app:layout_constraintEnd_toStartOf="@+id/img_search"

app:layout_constraintStart_toStartOf="@+id/view3"

app:layout_constraintTop_toTopOf="@+id/view3" />

<ListView

android:id="@+id/lv"

android:layout_width="0dp"

android:layout_height="0dp"

android:layout_marginStart="8dp"

android:layout_marginTop="16dp"

android:layout_marginEnd="8dp"

app:layout_constraintBottom_toBottomOf="parent"

app:layout_constraintEnd_toEndOf="parent"

app:layout_constraintStart_toStartOf="parent"

app:layout_constraintTop_toBottomOf="@+id/view3" />

</androidx.constraintlayout.widget.ConstraintLayout>

XML

5.我的页面

1.信息部分:用户点击后可查看详细信息,点击后跳转至InformationActivity。

2.修改密码部分:用户点击后可修改密码,点击后跳转至ModifyPassWordActivity。

3.版本部分:用户点击后可查看当前应用程序版本信息,通过Toast消息显示当前版本号。

4.退出部分:用户点击后退出应用程序,点击后跳转至登录页面(LoginActivity),并结束当前活动。

图片

<?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:layout_width="match_parent"

android:layout_height="match_parent"

tools:context=".Fragment.MineFragment">

<View

android:id="@+id/view6"

android:layout_width="wrap_content"

android:layout_height="50dp"

android:background="#00BCD4"

app:layout_constraintEnd_toEndOf="parent"

app:layout_constraintStart_toStartOf="parent"

app:layout_constraintTop_toTopOf="parent" />

<TextView

android:id="@+id/textViews8"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="个人中心"

android:textColor="#fff"

android:textSize="20sp"

android:textStyle="bold"

app:layout_constraintBottom_toBottomOf="@+id/view6"

app:layout_constraintEnd_toEndOf="parent"

app:layout_constraintStart_toStartOf="parent"

app:layout_constraintTop_toTopOf="@+id/view6" />

<ImageView

android:id="@+id/imageView14"

android:layout_width="match_parent"

android:layout_height="170dp"

android:scaleType="centerCrop"

android:src="@drawable/studywd"

app:layout_constraintEnd_toEndOf="parent"

app:layout_constraintStart_toStartOf="parent"

app:layout_constraintTop_toBottomOf="@+id/view6" />

<LinearLayout

android:layout_width="0dp"

android:layout_height="0dp"

android:orientation="vertical"

app:layout_constraintBottom_toBottomOf="parent"

app:layout_constraintEnd_toEndOf="parent"

app:layout_constraintStart_toStartOf="parent"

app:layout_constraintTop_toBottomOf="@+id/imageView14">

<LinearLayout

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:gravity="center"

android:orientation="vertical"

android:padding="10dp">

</LinearLayout>

<LinearLayout

android:id="@+id/ll_information"

android:layout_width="match_parent"

android:layout_height="40dp"

android:background="#fff"

android:gravity="center|left"

android:orientation="horizontal"

android:padding="10dp">

<ImageView

android:id="@+id/imageView2"

android:layout_width="20dp"

android:layout_height="20dp"

android:layout_marginLeft="10dp"

android:src="@drawable/information" />

<TextView

android:id="@+id/textView5"

android:layout_width="wrap_content"

android:layout_height="match_parent"

android:layout_marginLeft="8dp"

android:layout_weight="1"

android:gravity="center|left"

android:text="个人信息"

android:textColor="#000"

android:textSize="13sp" />

<ImageView

android:id="@+id/imageView3"

android:layout_width="15dp"

android:layout_height="match_parent"

android:layout_marginRight="10dp"

android:src="@drawable/right" />

</LinearLayout>

<LinearLayout

android:id="@+id/ll_password"

android:layout_width="match_parent"

android:layout_height="40dp"

android:layout_marginTop="20dp"

android:background="#fff"

android:gravity="center|left"

android:orientation="horizontal"

android:padding="10dp">

<ImageView

android:id="@+id/imageView12"

android:layout_width="20dp"

android:layout_height="20dp"

android:layout_marginLeft="10dp"

android:src="@drawable/password" />

<TextView

android:id="@+id/textView10"

android:layout_width="wrap_content"

android:layout_height="match_parent"

android:layout_marginLeft="8dp"

android:layout_weight="1"

android:gravity="center|left"

android:text="修改密码"

android:textColor="#000"

android:textSize="13sp" />

<ImageView

android:id="@+id/imageView13"

android:layout_width="15dp"

android:layout_height="match_parent"

android:layout_marginRight="10dp"

android:src="@drawable/right" />

</LinearLayout>

<LinearLayout

android:id="@+id/ll_versions"

android:layout_width="match_parent"

android:layout_height="40dp"

android:layout_marginTop="20dp"

android:background="#fff"

android:gravity="center|left"

android:orientation="horizontal"

android:padding="10dp">

<ImageView

android:id="@+id/imageView8"

android:layout_width="20dp"

android:layout_height="20dp"

android:layout_marginLeft="10dp"

android:src="@drawable/banben" />

<TextView

android:id="@+id/textView8"

android:layout_width="wrap_content"

android:layout_height="match_parent"

android:layout_marginLeft="8dp"

android:layout_weight="1"

android:gravity="center|left"

android:text="当前版本"

android:textColor="#000"

android:textSize="13sp" />

<ImageView

android:id="@+id/imageView9"

android:layout_width="15dp"

android:layout_height="match_parent"

android:layout_marginRight="10dp"

android:src="@drawable/right" />

</LinearLayout>

<LinearLayout

android:id="@+id/ll_quit"

android:layout_width="match_parent"

android:layout_height="40dp"

android:layout_marginTop="20dp"

android:background="#fff"

android:gravity="center|left"

android:orientation="horizontal"

android:padding="10dp">

<ImageView

android:id="@+id/imageView10"

android:layout_width="20dp"

android:layout_height="20dp"

android:layout_marginLeft="10dp"

android:src="@drawable/quit" />

<TextView

android:id="@+id/textView9"

android:layout_width="wrap_content"

android:layout_height="match_parent"

android:layout_marginLeft="8dp"

android:layout_weight="1"

android:gravity="center|left"

android:text="退出登录"

android:textColor="#000"

android:textSize="13sp" />

<ImageView

android:id="@+id/imageView11"

android:layout_width="15dp"

android:layout_height="match_parent"

android:layout_marginRight="10dp"

android:src="@drawable/right" />

</LinearLayout>

</LinearLayout>

</androidx.constraintlayout.widget.ConstraintLayout>

XML

6.个人信息页面

显示用户注册时的信息

图片

7.修改密码页面

图片

Get项目源码

快捷获取方式

网址:基于Android Studio 垃圾分类助手App https://www.yuejiaxmz.com/news/view/1331247

相关内容

推荐文章:探索环保新境界 —— “垃圾分类助手”APP
android app实现多种语音,基于Android的语音助手APP
基于安卓android studio 的 菜谱食谱APP设计
垃圾分类助手
基于Android studio的二手交易平台
基于Android的个人助理APP设计与实现毕业论文
智能家居手机app控制android studio 手机app操控智能家居
基于腾讯云开发的智能垃圾分类微信小程序
垃圾分类助手app下载
基于Android的家庭医务助手APP [Android]—计算机毕业设计源码+文档

随便看看