Android studio课程设计开发实现---日记APP
Android studio课程设计开发实现—日记APP
文章目录
- Android studio课程设计开发实现---日记APP
- 前言
- 一、效果
- 二、功能介绍
- 1.主要功能
- 2.涉及知识点
- 三、实现思路
- 总结
前言
你们好,我是oy,介绍一个简易日记APP。
一、效果
1.启动页、引导页及登陆注册
2.日记相关功能
3.个人中心界面
二、功能介绍
1.主要功能
- 实现应用启动页及引导页
- 实现设置密码进入APP,对密码进行加密处理
- 实现底部导航栏,分为日记列表,新建日记,个人中心模块
- 实现对日记删除、修改、新增的基础功能
- 实现圆形头像,通过相册及拍照并裁剪图片设置头像。可实时保存。
- 实现网络更新个人中心美图。
- 对密码展示及关闭,跳转应用设置界面
- 动态获取拍照及相册访问权限
…
…
2.涉及知识点
- activity与fragment数据传递、页面更新、相互跳转。
- SharedPrefrenced存储、文件存储、文件加密。
- Android应用权限获取及设置
- 控件的使用:Button、EditText、AlertDialog、Imageview、ImageButton、viewPager2、Toolbar、RecycleView、NavigationButton等
- 布局的使用:LinearLayout、ConstraintLayout、RelativeLayout等
- 调用Android系统应用
- 自定义View:底部弹窗(比较复杂)、圆形头像
- Glide框架使用:网络加载图片
- Android框架:MVC
…
…
三、实现思路
- MainActivity中使用BottomNavigationView、ViewPager2、Toolbar实现。
public class MainActivity extends AppCompatActivity {private BottomNavigationView bottomNavigationView;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);initToolbar();initFragment();initNavigationBottom();}@SuppressLint("ResourceAsColor")private void initNavigationBottom() {bottomNavigationView = findViewById(R.id.navigation_bottom);bottomNavigationView.setItemIconTintList(null);bottomNavigationView.setOnNavigationItemSelectedListener(itemSelectedListener);}@Overridepublic boolean onCreateOptionsMenu(Menu menu) {return super.onCreateOptionsMenu(menu);}private void initFragment() {DiariesFragment diariesFragment = getDiariesFragment();if (diariesFragment == null) {diariesFragment = new DiariesFragment();ActivityUtils.addFragmentToActivity(getSupportFragmentManager(), diariesFragment, R.id.content);}}private DiariesFragment getDiariesFragment() {return (DiariesFragment) getSupportFragmentManager().findFragmentById(R.id.content);}private void initToolbar() {//设置顶部状态栏为透明getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);Toolbar toolbar = findViewById(R.id.toolbar);setSupportActionBar(toolbar);}private final BottomNavigationView.OnNavigationItemSelectedListener itemSelectedListener = item -> {switch (item.getItemId()) {case R.id.menu_diary:MeController.setToolbarVisibility(this);ActivityUtils.removeFragmentTOActivity(getSupportFragmentManager(), getSupportFragmentManager().findFragmentById(R.id.content));ActivityUtils.addFragmentToActivity(getSupportFragmentManager(), new DiariesFragment(), R.id.content);break;case R.id.menu_me:findViewById(R.id.toolbar).setVisibility(View.GONE);ActivityUtils.removeFragmentTOActivity(getSupportFragmentManager(), getSupportFragmentManager().findFragmentById(R.id.content));ActivityUtils.addFragmentToActivity(getSupportFragmentManager(), new MeFragment(), R.id.content);break;case R.id.menu_new:bottomNavigationView.setVisibility(View.GONE);MeController.setToolbarVisibility(this);ActivityUtils.removeFragmentTOActivity(getSupportFragmentManager(), getSupportFragmentManager().findFragmentById(R.id.content));ActivityUtils.addFragmentToActivity(getSupportFragmentManager(), new AddDiaryFragment(), R.id.content);break;}return true;};
}
MainActivity的layout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayoutxmlns: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"tools:context=".MainActivity"><com.google.android.material.appbar.AppBarLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"><androidx.appcompat.widget.Toolbarandroid:id="@+id/toolbar"android:layout_width="match_parent"android:layout_height="wrap_content"android:background="?attr/colorPrimary"android:minHeight="?attr/actionBarSize"android:fitsSystemWindows="true"android:theme="@style/Widget.AppCompat.Toolbar"app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/></com.google.android.material.appbar.AppBarLayout><FrameLayoutandroid:id="@+id/content"android:layout_width="match_parent"android:layout_height="0dp"android:layout_weight="1"/><com.google.android.material.bottomnavigation.BottomNavigationViewandroid:id="@+id/navigation_bottom"android:layout_width="match_parent"android:layout_height="wrap_content"app:menu="@menu/menu_navigation"android:background="?android:attr/windowBackground"/></LinearLayout>
- ViewPager2中切换不同fragment,对应导航栏新增日记、个人中心及日记列表。
public class DiariesFragment extends Fragment {private DiariesController mController;@Overridepublic void onCreate(@Nullable Bundle savedInstanceState) {super.onCreate(savedInstanceState);mController = new DiariesController(this);}@Nullable@Overridepublic View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {View root = inflater.inflate(R.layout.fragment_diaries, container, false);mController.setDiariesList(root.findViewById(R.id.diaries_list));return root;}@Overridepublic void onResume() {super.onResume();mController.loadDiaries();}
}
DiariesFragment的layout
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent" android:layout_height="match_parent"android:orientation="vertical"><androidx.recyclerview.widget.RecyclerViewandroid:id="@+id/diaries_list"android:layout_width="match_parent"android:layout_height="wrap_content"/></RelativeLayout>
public class AddDiaryFragment extends Fragment implements View.OnClickListener {private AddDiaryController mController;private View edit_layout;private Button btn_confirm;private EditText edit_title;private EditText edit_desc;@Overridepublic void onCreate(@Nullable Bundle savedInstanceState) {super.onCreate(savedInstanceState);mController = new AddDiaryController(this);}private void initView(View view) {btn_confirm = view.findViewById(R.id.add_diary_confirm);btn_confirm.setOnClickListener(this);edit_title = view.findViewById(R.id.edit_add_title);edit_desc = view.findViewById(R.id.edit_add_desc);edit_layout = view.findViewById(R.id.edit_layout);edit_layout.setOnClickListener(this);}@Overridepublic void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {inflater.inflate(R.menu.menu_cancel, menu);}@Overridepublic boolean onOptionsItemSelected(@NonNull MenuItem item) {switch (item.getItemId()) {case R.id.menu_cancel:mController.closeWriteDiary(getActivity().getSupportFragmentManager(), this);mController.setNavigationVisibility();return true;}return false;}@Nullable@Overridepublic View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {View root = inflater.inflate(R.layout.fragment_add_diary, container, false);initView(root);return root;}@Overridepublic void onDestroy() {super.onDestroy();}@Overridepublic void onClick(View view) {switch (view.getId()) {case R.id.add_diary_confirm:mController.addDiaryToRepository(edit_title.getText().toString().trim(), edit_desc.getText().toString().trim());mController.setNavigationVisibility();mController.closeWriteDiary(getActivity().getSupportFragmentManager(), this);break;case R.id.edit_layout:mController.changeFocus(edit_desc);break;}}
}
AddDiaryFragment的layout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical"><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginTop="10dp"android:layout_marginStart="10dp"android:layout_marginEnd="10dp"android:orientation="vertical"><EditTextandroid:id="@+id/edit_add_title"android:hint="@string/add_title_hint"android:minLines="1"android:layout_width="match_parent"android:layout_height="wrap_content" /></LinearLayout><LinearLayoutandroid:id="@+id/edit_layout"android:layout_width="match_parent"android:layout_height="0dp"android:layout_weight="1"android:layout_marginTop="5dp"android:layout_marginStart="10dp"android:layout_marginEnd="10dp"android:layout_marginBottom="10dp"><LinearLayoutandroid:layout_width="match_parent"android:layout_height="match_parent"android:paddingStart="5dp"android:paddingTop="5dp"android:paddingEnd="5dp"android:paddingBottom="5dp"android:background="@drawable/edit_background"><EditTextandroid:id="@+id/edit_add_desc"android:hint="@string/add_title_description"android:gravity="top"android:layout_width="match_parent"android:layout_height="wrap_content"android:scrollbars="vertical"android:background="@null"/></LinearLayout></LinearLayout><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:gravity="center"android:orientation="horizontal"><Buttonandroid:id="@+id/add_diary_confirm"android:text="@string/btn_ok"android:layout_width="wrap_content"android:layout_height="wrap_content"/></LinearLayout>
</LinearLayout>
- 将应用密码加密保存与文件中。每次登陆获取密码并对比。
public class LoginDirectActivity extends AppCompatActivity implements View.OnClickListener {private EditText edit_input_text;private Button btn_comeIn;private TextView tv_setPsw;private static final String TAG = "Login2Activity";@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_direct_login);bindView();}private void bindView() {getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);edit_input_text = findViewById(R.id.edit_login2_input_text);btn_comeIn = findViewById(R.id.btn_login2_comeIn);btn_comeIn.setOnClickListener(this);tv_setPsw = findViewById(R.id.tv_setPsw);tv_setPsw.setOnClickListener(this);}@Overridepublic void onClick(View v) {switch (v.getId()) {case R.id.tv_setPsw:Intent setPsw_intent = new Intent(LoginDirectActivity.this, LoginActivity.class);startActivity(setPsw_intent);LoginDirectActivity.this.finish();
// overridePendingTransition(R.anim.out_to_left,R.anim.in_from_right);break;case R.id.btn_login2_comeIn:String psw = edit_input_text.getText().toString().trim();if (psw.isEmpty()) {Toast.makeText(this, "密码不能为空!", Toast.LENGTH_SHORT).show();return;}String readInfoByContext = FileUtils.readInfoByContext(this);if (psw.equals(readInfoByContext)) {Toast.makeText(this, "登录成功!", Toast.LENGTH_SHORT).show();Intent intent = new Intent(this, MainActivity.class);startActivity(intent);
// overridePendingTransition(R.anim.out_to_left,R.anim.in_from_right);} else {Toast.makeText(this, "密码不正确!", Toast.LENGTH_SHORT).show();}break;}}
}
LoginDirectActivity 的layout
<?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=".view.LoginDirectActivity"><Buttonandroid:id="@+id/btn_login2_comeIn"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginStart="40dp"android:layout_marginEnd="40dp"android:text="进入"app:layout_constraintBottom_toTopOf="@+id/guideline5"app:layout_constraintEnd_toEndOf="parent"app:layout_constraintStart_toStartOf="parent" /><LinearLayoutandroid:id="@+id/linearLayout"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginStart="40dp"android:layout_marginEnd="40dp"android:gravity="center_vertical"android:orientation="horizontal"app:layout_constraintEnd_toEndOf="parent"app:layout_constraintStart_toStartOf="parent"app:layout_constraintTop_toTopOf="@+id/guideline7"><ImageViewandroid:layout_width="32dp"android:layout_height="32dp"android:src="@mipmap/come_in_key" /><EditTextandroid:id="@+id/edit_login2_input_text"android:hint="输入您的密码"android:inputType="textPassword"android:layout_width="match_parent"android:layout_height="wrap_content" /></LinearLayout><androidx.constraintlayout.widget.Guidelineandroid:id="@+id/guideline4"android:layout_width="wrap_content"android:layout_height="wrap_content"android:orientation="horizontal"app:layout_constraintGuide_percent="0.22" /><androidx.constraintlayout.widget.Guidelineandroid:id="@+id/guideline5"android:layout_width="wrap_content"android:layout_height="wrap_content"android:orientation="horizontal"app:layout_constraintGuide_percent="0.58" /><TextViewandroid:id="@+id/tv_login2_password_title"android:layout_width="match_parent"android:layout_height="wrap_content"android:gravity="center"android:text="输入密码"android:textSize="30sp"android:textStyle="bold"app:layout_constraintEnd_toEndOf="parent"app:layout_constraintStart_toStartOf="parent"app:layout_constraintTop_toTopOf="@+id/guideline4" /><androidx.constraintlayout.widget.Guidelineandroid:id="@+id/guideline7"android:layout_width="wrap_content"android:layout_height="wrap_content"android:orientation="horizontal"app:layout_constraintGuide_percent="0.4" /><TextViewandroid:id="@+id/tv_setPsw"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="设置密码"android:textStyle="bold"app:layout_constraintEnd_toEndOf="@+id/linearLayout"app:layout_constraintTop_toBottomOf="@+id/linearLayout" /></androidx.constraintlayout.widget.ConstraintLayout>
- 使用SharedPrefrenced存储日记内容及标题。
public final class SharedPreferencesUtils {private static final SimpleArrayMap<String, SharedPreferencesUtils> mCaches = new SimpleArrayMap<>();private SharedPreferences mSharedPreferences;private SharedPreferencesUtils(final String spName, final int mode) {mSharedPreferences = YyApplication.get().getSharedPreferences(spName, mode);}public static SharedPreferencesUtils getInstance(String spName) {SharedPreferencesUtils utils = mCaches.get(spName);if (utils == null) {utils = new SharedPreferencesUtils(spName, Context.MODE_PRIVATE);}return utils;}public void put(final String key, final String value) {mSharedPreferences.edit().putString(key, value).apply();}public String get(final String key) {return mSharedPreferences.getString(key, "");}public void remove(final String key) {mSharedPreferences.edit().remove(key).apply();}
}
总结
以上就是今天讲的内容,本文仅仅简单介绍了Android日记APP,需要掌握上述知识点,能够较好的理解此应用逻辑。
Android studio课程设计开发实现---日记APP相关推荐
- Android studio课程设计仿微信app开发
在学习安卓app开发之后,每学期都会有课程设计,我们要根据已经学习的知识做出一些东西,下面这个项目就是我做了很久. 1.功能模块 2.注册登陆模块 3.添加好友模块 4.聊天界面 5.朋友圈界面 6. ...
- android仿QQ列表实现 android studio大作业,android studio课程设计
1. 效果图 2.功能介绍:登录,注册,好友列表 3.核心代码 /*** 登录页面*/ public class LoginActivity extends BaseActivity {private ...
- Android studio心得——用fragment仿微信APP
前言 今天我想与大家分享一些关于如何利用fragment实现仿微信APP的经验.作为社交领域最受欢迎.功能齐全且可扩展性强的应用之一,微信APP在浏览器首页和个人中心之上还有一个重要部分:底部导航栏. ...
- android studio ndk-builld方式开发
之前都是在Ubuntu开发,项目也是老的,自然也就顺理成章的用eclipse做各种android的开发.最近想在android studio 切换下,有点不习惯.android studio 为ndk ...
- android Studio 配置LUA 开发环境
android Studio 配置 LUA 开发环境 关于Android LUA资料 android如何调用lua? Android lua 教程 Lua官网 lua语言解释 Lua 5.1 参考手册 ...
- 使用Android Studio 进行NDK开发和调试
2019独角兽企业重金招聘Python工程师标准>>> 尽管Android Studio已经越来越流行了,但很多人还是习惯于Eclipse或源码环境下开发JNI应用.个人认为使用An ...
- Android Studio实现内容丰富的旅游App
文章目录 一.项目概述 二.开发环境 三.项目结构 四.运行演示 五.项目总结 六.源码获取 一.项目概述 随着人们生活质量的不断提高,外出旅游的需求也日益增多,旅游肯定需要一款App来帮助游客寻找景 ...
- 使用 Android Studio 搭建安卓开发环境
使用 Android Studio 搭建安卓开发环境,方便.快捷.因为 Android SDK 等下载已经集成到 Android Studio 的安装中 1.官网下载 Android Studio ...
- Android让APP运行在新环境上,Android Studio环境在真手机运行app项目教程
对于Android Studio环境在真手机运行app项目的相关操作有许多网友咨询过,小编今天就分享Android Studio环境在真手机运行app项目的详细步骤,一起好好学习下吧! 要想将Andr ...
最新文章
- php pkcs 1格式的公钥,解说--2--微信支付RSA公钥PKCS1格式转化成PKCS8格式的公钥
- Maven : 将Jar安装到本地仓库和Jar上传到私服[转]
- 一文了解结构体字节对齐
- Vue 3 都 RC 了,前端的你还不来看看
- .Net Core迁移到MSBuild的多平台编译问题
- 武汉大学计算机学院 招聘院长,黄传河任武汉大学计算机学院执行副院长 主持工作...
- eclipse中自定义videoview类_android控件之VideoView建立自己的播放器
- 数学 之 hdu 4710 Balls Rearrangement
- 前端实现Word在线预览
- 程序员常用英语单词1700
- PDCA循环法,一个处处适用也必须掌握的管理方法
- flash移植到android上,Flash Web Game移植到Android平台需要注意的地方
- 基于NLP的中医医案文本快速结构化方法
- 区块链:剖析工作量证明
- 股票交易接口dll代码分享
- 中国好生意 经典论述:哈林是来主持的,刘欢是来开家长会的,那英是来唠嗑的,杨坤是来做宣传的,而......
- 基于stm32蓝牙智能小车设计
- PHP 获取客户端 IP 地址
- pn532写入手机nfc_NFC的PN532 读写命令格式
- Ghost 使用手册
热门文章
- 信息学奥赛一本通1003:对齐输出
- 程序员吃饭段子Java吃完就走_爆笑段子:一朋友是个程序员,有一次和他吃饭,他愁眉苦脸的说...
- 跳棋最少移动次数 java,跳棋
- OpenCV:remap()简单重映射
- AUTOSAR I-PDU的理解以及I-PDU的Callout
- 清华大学计算机陈蓓,清华大学2010级本科生新生代表座谈会举行
- 【算法分析】回溯法解数独(九宫格)算法
- 采用动态规划思维求解数塔问题,c++实现
- 怎么用软碟通制作U启动和再生龙恢复LINUX系统及备份
- qt项目在Linux平台上面发布成可执行程序.run