1、目录

2、代码

2.1 java

  1. ListActivity.java

    public class ListActivity extends Activity {private SQLiteDatabase db;private ListView list;@Overrideprotected void onCreate(@Nullable Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_list);db = openOrCreateDatabase("examDB", MODE_PRIVATE, null);list = findViewById(R.id.list);showList();}private void showList(){String [] from = {"goods", "money", "remark"};int [] to = {R.id.text_goods, R.id.text_money, R.id.text_remark};Cursor c = db.rawQuery("select * from account", null);if (c != null) {String[] goods = new String[c.getCount()];double[] money = new double[c.getCount()];String[] remark = new String[c.getCount()];int[] id = new int[c.getCount()];int len = 0;ArrayList<HashMap<String, Object>> data = new ArrayList<>();while(c.moveToNext()) {id[len] = c.getInt(0);goods[len] = c.getString(1);money[len] = c.getDouble(2);remark[len] = c.getString(3);++len;}for(int i = 0; i < len; ++i) {HashMap<String, Object> m = new HashMap<String, Object>();m.put("id", id[i]);m.put(from[0], goods[i]);m.put(from[1], money[i]);m.put(from[2], remark[i]);data.add(m);}SimpleAdapter adapter = new MyAdapter(this, data, R.layout.item, from, to);list.setAdapter(adapter);}}
    }
  2. LoginActivity.java
    public class LoginActivity extends Activity implements View.OnClickListener{private EditText edt_uname;private EditText edt_upass;private Button btn_login;@Overrideprotected void onCreate(@Nullable Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_login);register();}private void register(){edt_uname = findViewById(R.id.edt_uname);edt_upass = findViewById(R.id.edt_upass);btn_login = findViewById(R.id.btn_login);btn_login.setOnClickListener(this);}@Overridepublic void onClick(View view) {if(view.getId() == R.id.btn_login) {String uname = edt_uname.getText().toString();String upass = edt_upass.getText().toString();if("aaa".equals(uname) && "123".equals(upass)) {Intent it = new Intent(this, MainActivity.class);startActivity(it);this.finish();}else{Toast.makeText(this, "用名或密码错误", Toast.LENGTH_LONG).show();edt_upass.setText("");edt_upass.setText("");}}}
    }
  3. MainActivity.java
    public class MainActivity extends AppCompatActivity implements View.OnClickListener{private EditText edt_goods;private EditText edt_money;private EditText edt_remark;private Button btn_ji;private Button btn_look;private SQLiteDatabase db;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);register();InitDB();}private void register(){edt_goods = findViewById(R.id.goods);edt_money = findViewById(R.id.edt_money);edt_remark = findViewById(R.id.remark);btn_ji = findViewById(R.id.btn_ji);btn_look = findViewById(R.id.btn_look);btn_ji.setOnClickListener(this);btn_look.setOnClickListener(this);}private void InitDB() {db = openOrCreateDatabase("examDB", MODE_PRIVATE, null);db.execSQL("create table if not exists account(_id Integer primary key autoincrement, goods varchar, money double, remark varchar)");}@Overridepublic void onClick(View view) {if(view.getId() == R.id.btn_ji) {ji();}else{look();}}private void ji() {String insertSql = "insert into account(goods, money, remark)values(?,?,?)";String goods = edt_goods.getText().toString();double money = Double.valueOf(edt_money.getText().toString());String remark = edt_remark.getText().toString();Object[] ob = new Object[]{goods,money,remark};db.execSQL(insertSql, ob);Toast.makeText(this, "记录成功", Toast.LENGTH_LONG).show();edt_goods.setText("");edt_remark.setText("");edt_money.setText("");}private void look() {Intent it = new Intent(this, ListActivity.class);startActivity(it);}
    }
  4. MyAdapter.java
    public class MyAdapter extends SimpleAdapter{private LayoutInflater inflater;private Context context;private ArrayList<HashMap<String,Object>> mData;int p;private SQLiteDatabase db;public MyAdapter(Context context, List<? extends Map<String, ?>> data, int resource, String[] from, int[] to) {super(context, data, resource, from, to);this.context = context;mData = (ArrayList<HashMap<String, Object>>) data;this.db = context.openOrCreateDatabase("examDB", Context.MODE_PRIVATE, null);}@Overridepublic View getView(int position, View convertView, ViewGroup parent) {View v= super.getView(position, convertView, parent);Button btn_delete = (Button)v.findViewById(R.id.btn_delete);Button btn_update = (Button)v.findViewById(R.id.btn_update);p = position;btn_delete.setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View view) {new AlertDialog.Builder(context).setTitle("提示消息").setMessage("是否删除记录").setPositiveButton("确定", new DialogInterface.OnClickListener() {@Overridepublic void onClick(DialogInterface dialogInterface, int i) {int id  = (int) mData.get(p).get("id");mData.remove(p);Toast.makeText(context, "删除"+Integer.toString(p),Toast.LENGTH_LONG).show();String sql = "delete from account where _id = ?";Object[] ob = new Object[]{id};db.execSQL(sql, ob);MyAdapter.this.notifyDataSetChanged();}}).setNegativeButton("取消", null).show();}});btn_update.setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View view) {int id  = (int) mData.get(p).get("id");String goods = (String)mData.get(p).get("goods");double money = (double)mData.get(p).get("money");String remark = (String)mData.get(p).get("remark");Intent it = new Intent(context, UpdateActivity.class);it.putExtra("goods", goods);it.putExtra("money", money);it.putExtra("remark", remark);it.putExtra("id", id);context.startActivity(it);}});return v;}
    }
  5. UpdateActivity.java
    public class UpdateActivity extends Activity implements View.OnClickListener{private Button btn_update;private TextView goods;private TextView money;private TextView remark;private int id;@Overrideprotected void onCreate(@Nullable Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_update);Init();}public void Init() {Intent it = getIntent();goods = findViewById(R.id.goods);money = findViewById(R.id.money);remark = findViewById(R.id.remark);goods.setText(it.getStringExtra("goods"));money.setText(String.valueOf(it.getDoubleExtra("money", 0)));remark.setText(it.getStringExtra("remark"));id = it.getIntExtra("id", 0);btn_update = findViewById(R.id.btn_update);btn_update.setOnClickListener(this);}@Overridepublic void onClick(View view) {Intent it = new Intent(this, ListActivity.class);SQLiteDatabase db = openOrCreateDatabase("examDB", MODE_PRIVATE, null);String sql = "update account set goods=?,money=?, remark=? where _id=?";Object[] obj = new Object[]{goods.getText().toString(),Double.valueOf(money.getText().toString()),remark.getText().toString(),id};db.execSQL(sql, obj);startActivity(it);this.finish();}
    }

2.2 xml

  1. activity_list.xml

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent"tools:context=".ListActivity"><ListViewandroid:id="@+id/list"android:layout_width="match_parent"android:layout_height="match_parent"/></LinearLayout>
    
  2. activity_login.xml
    <?xml version="1.0" encoding="utf-8"?>
    <android.support.constraint.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=".LoginActivity"><TextViewandroid:id="@+id/textView"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginStart="64dp"android:layout_marginTop="120dp"android:text="用户名"app:layout_constraintStart_toStartOf="parent"app:layout_constraintTop_toTopOf="parent" /><TextViewandroid:id="@+id/textView2"android:layout_width="wrap_content"android:layout_height="29dp"android:layout_marginBottom="244dp"android:layout_marginStart="76dp"android:text="密码"app:layout_constraintBottom_toBottomOf="parent"app:layout_constraintStart_toStartOf="parent" /><EditTextandroid:id="@+id/edt_uname"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginEnd="28dp"android:layout_marginTop="96dp"android:ems="10"android:inputType="textPersonName"app:layout_constraintEnd_toEndOf="parent"app:layout_constraintTop_toTopOf="parent" /><Buttonandroid:id="@+id/btn_login"android:layout_width="wrap_content"android:layout_height="49dp"android:layout_marginBottom="140dp"android:layout_marginEnd="190dp"android:layout_marginStart="106dp"android:text="登录"app:layout_constraintBottom_toBottomOf="parent"app:layout_constraintEnd_toEndOf="parent"app:layout_constraintStart_toStartOf="parent" /><EditTextandroid:id="@+id/edt_upass"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginBottom="244dp"android:layout_marginEnd="28dp"android:ems="10"android:inputType="textPassword"app:layout_constraintBottom_toBottomOf="parent"app:layout_constraintEnd_toEndOf="parent" />
    </android.support.constraint.ConstraintLayout>
  3. activity_main.xml
    <?xml version="1.0" encoding="utf-8"?>
    <android.support.constraint.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=".MainActivity"><TextViewandroid:id="@+id/textView3"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginStart="46dp"android:layout_marginTop="55dp"android:text="商品名"app:layout_constraintStart_toStartOf="parent"app:layout_constraintTop_toTopOf="parent" /><TextViewandroid:id="@+id/textView4"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginStart="46dp"android:layout_marginTop="76dp"android:text="金额"app:layout_constraintStart_toStartOf="parent"app:layout_constraintTop_toBottomOf="@+id/textView3" /><TextViewandroid:id="@+id/textView5"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginBottom="256dp"android:layout_marginStart="44dp"android:text="备注"app:layout_constraintBottom_toBottomOf="parent"app:layout_constraintStart_toStartOf="parent" /><Buttonandroid:id="@+id/btn_ji"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginBottom="132dp"android:layout_marginStart="83dp"android:text="记一笔"app:layout_constraintBottom_toBottomOf="parent"app:layout_constraintStart_toStartOf="parent" /><EditTextandroid:id="@+id/goods"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginEnd="34dp"android:layout_marginTop="27dp"android:ems="10"android:inputType="textPersonName"app:layout_constraintEnd_toEndOf="parent"app:layout_constraintTop_toTopOf="parent" /><EditTextandroid:id="@+id/edt_money"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginBottom="46dp"android:layout_marginEnd="34dp"android:layout_marginTop="49dp"android:ems="10"android:inputType="textPersonName"app:layout_constraintBottom_toTopOf="@+id/remark"app:layout_constraintEnd_toEndOf="parent"app:layout_constraintTop_toBottomOf="@+id/goods" /><EditTextandroid:id="@+id/remark"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginBottom="252dp"android:layout_marginEnd="32dp"android:ems="10"android:inputType="textPersonName"app:layout_constraintBottom_toBottomOf="parent"app:layout_constraintEnd_toEndOf="parent" /><Buttonandroid:id="@+id/btn_look"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginBottom="132dp"android:layout_marginEnd="59dp"android:text="查看"app:layout_constraintBottom_toBottomOf="parent"app:layout_constraintEnd_toEndOf="parent" />
    </android.support.constraint.ConstraintLayout>
  4. activity_update.xml
    <?xml version="1.0" encoding="utf-8"?>
    <android.support.constraint.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=".UpdateActivity"><TextViewandroid:id="@+id/textView3"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginStart="46dp"android:layout_marginTop="55dp"android:text="商品名"app:layout_constraintStart_toStartOf="parent"app:layout_constraintTop_toTopOf="parent" /><TextViewandroid:id="@+id/textView4"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginStart="46dp"android:layout_marginTop="76dp"android:text="金额"app:layout_constraintStart_toStartOf="parent"app:layout_constraintTop_toBottomOf="@+id/textView3" /><TextViewandroid:id="@+id/textView5"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginBottom="256dp"android:layout_marginStart="44dp"android:text="备注"app:layout_constraintBottom_toBottomOf="parent"app:layout_constraintStart_toStartOf="parent" /><Buttonandroid:id="@+id/btn_update"android:layout_width="wrap_content"android:layout_height="61dp"android:layout_marginBottom="136dp"android:layout_marginEnd="213dp"android:layout_marginStart="83dp"android:text="更新"app:layout_constraintBottom_toBottomOf="parent"app:layout_constraintEnd_toEndOf="parent"app:layout_constraintHorizontal_bias="1.0"app:layout_constraintStart_toStartOf="parent" /><EditTextandroid:id="@+id/goods"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginEnd="34dp"android:layout_marginTop="27dp"android:ems="10"android:inputType="textPersonName"app:layout_constraintEnd_toEndOf="parent"app:layout_constraintTop_toTopOf="parent" /><EditTextandroid:id="@+id/money"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginBottom="46dp"android:layout_marginEnd="34dp"android:layout_marginTop="49dp"android:ems="10"android:inputType="textPersonName"app:layout_constraintBottom_toTopOf="@+id/remark"app:layout_constraintEnd_toEndOf="parent"app:layout_constraintTop_toBottomOf="@+id/goods" /><EditTextandroid:id="@+id/remark"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginBottom="252dp"android:layout_marginEnd="32dp"android:ems="10"android:inputType="textPersonName"app:layout_constraintBottom_toBottomOf="parent"app:layout_constraintEnd_toEndOf="parent" /></android.support.constraint.ConstraintLayout>
  5. item.xml
    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:orientation="horizontal"android:layout_width="match_parent"android:layout_height="match_parent"><TextViewandroid:id="@+id/text_goods"android:layout_width="81dp"android:layout_height="38dp"android:layout_weight="1"android:text="TextView"android:textSize="18sp" /><TextViewandroid:id="@+id/text_money"android:layout_width="85dp"android:layout_height="38dp"android:layout_weight="1"android:text="TextView"android:textSize="18sp" /><TextViewandroid:id="@+id/text_remark"android:layout_width="90dp"android:layout_height="38dp"android:layout_weight="1"android:text="TextView"android:textSize="18sp" /><Buttonandroid:id="@+id/btn_update"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_weight="1"android:text="更新" /><Buttonandroid:id="@+id/btn_delete"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_weight="1"android:text="删除" />
    </LinearLayout>
    
  6. AndroidManifest.xml
    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"package="com.example.asus.exam"><applicationandroid: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=".MainActivity"></activity><activity android:name=".LoginActivity"><intent-filter><action android:name="android.intent.action.MAIN" /><category android:name="android.intent.category.LAUNCHER" /></intent-filter></activity><activity android:name=".ListActivity"/><activity android:name=".UpdateActivity"/></application></manifest>

2019—2020年记账本APP相关推荐

  1. Android——一个简单的记账本APP

    一个简单的记账本APP 视频效果预览 添加账目记录 效果预览 添加账目记录实现 简述 实现 获取日期 字符串时间戳转Date Date转星期 获取时间 Switch控制显示和隐藏 更改Switch样式 ...

  2. 安卓开发记账本app

    安卓记账本app 功能实现 支出与收入的增删改查,饼状图实现占比动画展示.增加拍照功能 模块介绍 系统开发技术介绍 将数据以饼状图的形式展示占比 主要思想:通过sumValue求出数据库中所有数据的总 ...

  3. 基于微信小程序的小程序记账本APP源码

    运行环境: 微信平台或者微信开发者工具. 硬件环境: 微信开发者工具需要windows 7/8/10 2G内存以上(推荐4G,4G以上更好),手机环境安装微信APP即可 可以实现: 用户角色包含以下功 ...

  4. 画出记账本app的用例图

    好的,我将用中文为您画出记账本应用程序的用例图. 首先,记账本应用程序的主要用例是记录账目.在这个用例中,用户需要输入账目的类型(例如收入或支出).金额和日期,然后将账目保存到记账本中. 其次,记账本 ...

  5. AndroidStudio 制作一个超简易记账本App(1.0)【含详细步骤】

    先看最终效果: 1.首先创建一个Empty Activity 2.在activity_main.xml里编写主界面布局 根据预览图,主界面需要一个ListView和一个ImageButton,还要给I ...

  6. Android记账本APP开发进阶版

    记账本进阶内容: ①实现登录注册注册功能 ②进入后有四个界面 ③第一个就是记账页面(实时显示在记账页面) ④第二个是收支对比界面(实现收入金额滚动就像支付宝一样) ⑤第三个是图表展示界面 ⑥第四个是个 ...

  7. android记账app开发全过程,android开发实战-记账本APP(一)

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

  8. 记账本app的需求分析

    记账本应用程序的需求分析包括对应用程序的功能和性能进行评估,以确定应用程序的设计和开发应该包含哪些内容. 首先,应对记账本应用程序的用户进行用户调研,以了解用户的使用需求.这可以包括访问用户的使用情况 ...

  9. 记账本app开发的项目背景

    记账本应用是一种帮助人们记录.管理个人财务的工具.它的目的是帮助人们更好地理解自己的花费情况,并帮助他们做出更明智的财务决策.记账本应用可以让人们轻松地记录支出和收入,并通过图表和报告功能帮助人们更直 ...

最新文章

  1. 测试方案_何小伟:ABTest测试方案
  2. 一步一步实现扫雷游戏(C语言实现)(三)
  3. 蚁群算法优化神经网络matlab源程序,粒子群优化神经网络的程序大集合
  4. LeetCode - 695. Max Area of Island (Java)
  5. FreeRTOS学习笔记之信号量
  6. 关于Ubuntu20.04 sudo vi找不到命令解决方法
  7. jsp页面div上下滑动_H5单页面手势滑屏切换原理
  8. 在js中访问html页面,javascript – 在IE9的html页面中访问js里面的全局函数
  9. css宋体代码_family【CSS 字体】(宋体 黑体 微软雅黑)CSS文字字体
  10. javaShop JAVA版多用户B2B2C商城源码(PC +H5+小程序+APP)
  11. [歌词]《一花依世界》《君がいる世界へ》歌词假名罗马音
  12. 淘宝订单自动确认收货的N种实现,秒杀面试官
  13. 解决使用shutil.rmtree无法删除文件夹的方案
  14. 猴子偷桃c语言编程软件,C语言实现的猴子偷桃之类算法
  15. 分布式数据库 Tracing (一)— Opentracing
  16. 怎么让浏览器一直前置_上海居住证积分没有前置学历怎么解决?
  17. ROS学习----依据ROS入门教程,整理的ROS命令
  18. 计算机如何接两个屏幕,笔记本连接两个显示器的步骤_笔记本电脑怎么外接两个显示器做分屏-win7之家...
  19. Matlab Mobile手机版获取gps数据和加速度信号融合
  20. 使用Qt绘图制作一个钟表

热门文章

  1. 20162329 张旭升 实验二:实验报告
  2. python和java段子_python程序员幽默段子_谁说码农不懂幽默?只有程序员才看得懂的段子...
  3. Java内部类(一篇就够)
  4. 都是韭菜,不配做后浪
  5. 全栈python之路——三篇文章带你踏入python大门-基础02
  6. 光棍节程序员闯关秀第5关(总共10关)
  7. iOS 判断手机型号及系统版本(包括iPhone 11系列)
  8. 想剑网三妹子最多服务器,224人一起捏刘亦菲?剑网三妹子刚进游戏,就整了个花木兰出来...
  9. python小球弹跳_python3.6使用tkinter实现弹跳小球游戏
  10. SQL:SQL 指令大全