今天实现的内容有:添加账本信息,个人头像的切换,密码的修改,退出登录。

添加账本信息有三个功能:

①记一笔支出项目

②记一笔收入项目

③清空所有项目

在此期间遇到的困难有:Activity与Fragment之间数值的传递问题,我利用Bundle对象来进行传值,但是布局文件中fragment里的name=“Account_Fragment”,这里暂时没有想到如何传值。

因此暂时将name="Find_Message"这个还未改变的一个fragment,当再次点击Account图标时,就可以传进去参数。

未解决的事:

①记完账本后,按日期排序一直不对

②初始Fragment没办法传参

明天要做的事:

先将上述问题解决,在设置长按项目进行单独删除。

统计总的收入与支出的对比

找到合适的图标进行替换

学习hellochart,将数据以饼状图展示。

今日成果:

点击更换头像:会有几个头像供选择

当点击后自动跳回个人信息界面:

其次是更换密码:需要输入原密码与新密码

再者就是记账的页面:有支出,收入,删除所有,支出的会显示红色,收入的会显示绿色

当点击收入时,会弹出一个框来进行记账

同理,当点击支出时,也会弹出一个框

当点击删除所有时,会将所有账目全部删除。

Account_Fragment:记账的Fragment

package com.example.countbook;

import android.app.AlertDialog;
import android.app.Fragment;
import android.content.DialogInterface;
import android.database.Cursor;
import android.graphics.Color;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.RadioButton; import androidx.annotation.Nullable; import java.util.ArrayList;
import java.util.List; public class Account_Fragment extends Fragment {
private List<Account> list;
private AccountOperator accountOperator;
private AccountAdapter accountAdapter;
Button btn_shouru;
Button btn_zhichu;
Button btn_delete;
Bundle bundle;
String username;
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
bundle=getArguments();
username=bundle.getString("username");
//Log.i("username",username);
}
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
View view=inflater.inflate(R.layout.account_fragment,null);
btn_shouru=(Button)view.findViewById(R.id.btn_shouru);
btn_zhichu=(Button)view.findViewById(R.id.btn_zhichu);
btn_delete=(Button)view.findViewById(R.id.btn_delete); accountOperator=new AccountOperator(view.getContext());
list=new ArrayList<>();
ListView AccountList=(ListView)view.findViewById(R.id.lv_main);
inin(username);
accountAdapter=new AccountAdapter(view.getContext(),list);
AccountList.setAdapter(accountAdapter);
btn_zhichu.setOnClickListener(l);
btn_shouru.setOnClickListener(l);
btn_delete.setOnClickListener(l);
return view;
}
View.OnClickListener l=new View.OnClickListener() {
@Override
public void onClick(View v) {
switch (v.getId()){
case R.id.btn_zhichu:
AlertDialog.Builder builder=new AlertDialog.Builder(getView().getContext());
LayoutInflater inflater=LayoutInflater.from(getView().getContext());
View viewDialog=inflater.inflate(R.layout.new_cost_data,null);
final EditText content=(EditText)viewDialog.findViewById(R.id.et_cost_content);
final DatePicker data=(DatePicker)viewDialog.findViewById(R.id.dp_cost_data);
final EditText money=(EditText)viewDialog.findViewById(R.id.et_cost_money);
final RadioButton rb1=(RadioButton)viewDialog.findViewById(R.id.rb1);
final RadioButton rb2=(RadioButton)viewDialog.findViewById(R.id.rb2);
final RadioButton rb3=(RadioButton)viewDialog.findViewById(R.id.rb3);
final RadioButton rb4=(RadioButton)viewDialog.findViewById(R.id.rb4); builder.setView(viewDialog);
builder.setTitle("New Cost");
builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Account bean=new Account();
bean.author=username;
bean.content=content.getText().toString();
bean.money=Integer.parseInt(money.getText().toString());
bean.date=data.getYear()+"-"+(data.getMonth()+1)+"-"+data.getDayOfMonth();
if(rb1.isChecked()){
bean.title=rb1.getText().toString();
}else if(rb2.isChecked()){
bean.title=rb2.getText().toString();
}else if(rb3.isChecked()){
bean.title=rb3.getText().toString();
}else if(rb4.isChecked()){
bean.title=rb4.getText().toString();
}
accountOperator.insert(bean);
list.add(bean);
accountAdapter.notifyDataSetChanged();
}
});
builder.setNegativeButton("Cancel",null);
builder.create().show();
break; case R.id.btn_shouru:
AlertDialog.Builder builder2=new AlertDialog.Builder(getView().getContext());
LayoutInflater inflater2=LayoutInflater.from(getView().getContext());
View viewDialog2=inflater2.inflate(R.layout.new_income_data,null);
final EditText content2=(EditText)viewDialog2.findViewById(R.id.et_income_content);
final DatePicker data2=(DatePicker)viewDialog2.findViewById(R.id.dp_income_data);
final EditText money2=(EditText)viewDialog2.findViewById(R.id.et_income_money);
final RadioButton frb1=(RadioButton)viewDialog2.findViewById(R.id.rb1);
final RadioButton frb2=(RadioButton)viewDialog2.findViewById(R.id.rb2);
final RadioButton frb3=(RadioButton)viewDialog2.findViewById(R.id.rb3); builder2.setView(viewDialog2);
builder2.setTitle("New InCome");
builder2.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Account bean=new Account();
bean.author=username;
bean.content=content2.getText().toString();
bean.money=Integer.parseInt(money2.getText().toString());
bean.date=data2.getYear()+"-"+(data2.getMonth()+1)+"-"+data2.getDayOfMonth();
if(frb1.isChecked()){
bean.title=frb1.getText().toString();
}else if(frb2.isChecked()){
bean.title=frb2.getText().toString();
}else if(frb3.isChecked()){
bean.title=frb3.getText().toString();
}
accountOperator.insert(bean);
list.add(bean);
accountAdapter.notifyDataSetChanged();
}
});
builder2.setNegativeButton("Cancel",null);
builder2.create().show();
break;
case R.id.btn_delete:
accountOperator.deleteall(username);
list.clear();
accountAdapter.notifyDataSetChanged();
break; }
}
}; private void inin(String author) {
Cursor cursor= (Cursor) accountOperator.findall(author);
if(cursor!=null){
while(cursor.moveToNext()){
Account bean=new Account();
bean.content=cursor.getString(cursor.getColumnIndex("content"));
bean.money=cursor.getInt(cursor.getColumnIndex("money"));
bean.date=cursor.getString(cursor.getColumnIndex("date"));
bean.title=cursor.getString(cursor.getColumnIndex("title"));
list.add(bean);
}
cursor.close();
}
}
}

安卓开发实战-记账本APP(四)的更多相关文章

  1. 安卓开发实战-记账本APP(六)

    记账本APP开发---终结篇 昨天的动态数字录屏奉上:在抖音上拍了一个(ps:欢迎点赞) https://v.douyin.com/poEjmG/ 今天将图表的内容进行了制作,我用的是MPChart的 ...

  2. 安卓开发实战-记账本APP(三)

    本次实现的是有关登录,注册和整体页面的改观,实现下方选项导致页面的切换效果. 利用到的技术有Sqlite数据库的增删改查,与fragment实现.由于暂时没有找到合适的图标,先借用微信的图标暂代一下. ...

  3. 安卓开发实战-记账本APP(五)

    今天将昨天剩余的bug修复,并且完成图标的美化,设置长按删除,模仿支付宝实现金额的动态增加. ①将昨天的布局进行了修改:之前是fragment,改成FrameLayout布局,不再设置name,进而在 ...

  4. android开发实战-记账本APP(二)

    继昨天的开发,继续完成今天的内容. (一)开始构建一些业务逻辑,开始构建记账本的添加一笔记账的功能. ①对fab按钮的click时间进行修改,创建一个AlertDialog.Builder对象,因此我 ...

  5. android开发实战-记账本APP(一)

    记账本开发流程: 对于一个记账本的初步开发而言,我实现的功能有: ①实现一个记账本的页面 ②可以添加数据并更新到页面中 ③可以将数据信息以图表的形式展现 (一)首先,制作一个记账本的页面. ①在系统自 ...

  6. Android开发实战——记账本(2)

    开发日志(2)——Bean目录以及数据库 首先编写一些自己生成的数据进行测试,看一下能否显示在模拟器上.那前提就是先写出bean目录,这和之前学的Javaweb步骤差不多.bean目录有三个变量事件. ...

  7. Android开发实战——记账本(4)

    开发日志(4)——MainActivity 在MainActivity中编写了几个方法.首先,点击账本的一条记录可以选择删除他,然后重写了fab,使之在点击他后能够添加记录.还写了删除全部记录的方法. ...

  8. Android开发实战——记账本(6)

    开发日志——(6) 今天将app签名打包,并部署在了真机上.真机上的截图: 运行成功:

  9. Android开发实战——记账本(5)

    开发日志——(5)     今天打算将图标的功能实现,将打开图表的选项放在右上方,所以重写MainActivity中的onOptionsItemSelected方法.增添Chart选项 public ...

随机推荐

  1. 从零开始のcocos2dx生活(六)EventDispatcher

    EventDispatcher可能是所有的里面比较不容易理解也不容易看的 我说自己的理解可能会误导到你们-[索了你们看不下去>< 我写了几乎所有的代码的注释,有的是废话跳过就好 主要的代码 ...

  2. 微信支付与支付宝支付java开发注意事项

    说明:这里只涉及到微信支付和淘宝支付 以官网的接口为准,主要关注[网关].[接口].[参数][加密方式][签名][回调] 第一步,了解自己的项目要集成的支付方式 常见的有扫码支付.网页支付.APP支付 ...

  3. VS Code 解决 因为在此系统上禁止运行脚本

    vscode执行命令的 主要是由于没有权限执行脚本.开通权限就可以解决啦 在搜索框中输入:powerShell 选择管理员身份运行 输入命令行:set-ExecutionPolicy RemoteSi ...

  4. 「UVA1328」「POJ1961」 Period 解题报告

    UVA1328 Period 其他链接:luogu UVA1328 POJ1961 For each prefix of a given string S with N characters (eac ...

  5. 入门gulp前端构建工具

    1. 全局安装 gulp:(倘若之前电脑安装过,则跳过此步骤) $ cnpm install -g gulp 2. 作为项目的开发依赖(devDependencies)安装: (此步骤会自动在目录下创 ...

  6. 关于ESP8266 NodeCMU固件无法刷入新代码的解决方法

    在玩ESP8266时,有时候会无意中写了导致死循环的代码,或都某些函数传递了不合适的参数导致系统崩溃,这可能会导致ES8266不停地重启,这时我们发现无法刷入新的代码,也无法删除8266中的原代码.我 ...

  7. Java之Object类用法总结

    Object类概述: 1.Object类是所有Java类的根父类. 2.如果在类的声明中未使用extends关键字指明其父类, 则默认父类为java.lang.Object类. Object类主要结构 ...

  8. Spring Boot从零入门3_创建Hello World及项目剖析

    目录 1 前言 2 名词术语 3 创建Hello World项目 3.1 基于STS4创建项目 3.2 使用Spring Initializr Website创建项目并导入 3.3 基于Spring ...

  9. 第一篇博客-- 走上IT路

    首先介绍一下本人,我是一名在校大学生,在一次学长分享学习经验时了解到,写博客可以帮助复习.所以这就是我要写博客的原因. 我是非常喜欢网络安全技术,因此我选择了我这个专业.在接下来的一段时间我会在这里记 ...

  10. 常见基本数据结构——树,二叉树,二叉查找树,AVL树

    常见数据结构——树 处理大量的数据时,链表的线性时间太慢了,不宜使用.在树的数据结构中,其大部分的运行时间平均为O(logN).并且通过对树结构的修改,我们能够保证它的最坏情形下上述的时间界. 树的定 ...