2021/5/20 工作日报 -- 简约记账app -- day5

今日完成了简约记账app的搜索界面,实现了根据备注模糊搜索记录的功能,点击搜索图标会自动弹出键盘。同时,开始绘制更多页面,目前仅设置了关于按钮的点击事件,关于页面也已添加。意识到数据库操作的重要性。
摘要由CSDN通过智能技术生成

今日计划

继续app的开发

今日完成情况

  1. 搜索界面的绘制,以及逻辑代码的编写,可以根据备注信息查询某一条记录,点击搜索图标可以自动弹出键盘,同时可以模糊搜索。
    在这里插入图片描述
    在这里插入图片描述
    首先在数据库管理类中添加,搜索的代码
    /**
     * 根据备注搜索收入或者支出的情况列表
     */
    public static List<AccountBean> getAccountListByRemarkFromAccounttb (String beizhu) {
        List<AccountBean> list = new ArrayList<>();
        String sql = "select * from accounttb where beizhu like '%" + beizhu +"%'";
        Cursor cursor = db.rawQuery(sql, null);
        while (cursor.moveToNext()) {
            int id = cursor.getInt(cursor.getColumnIndex("id"));
            String typeName = cursor.getString(cursor.getColumnIndex("typeName"));
            String bz = cursor.getString(cursor.getColumnIndex("beizhu"));
            String time = cursor.getString(cursor.getColumnIndex("time"));
            int sImageId = cursor.getInt(cursor.getColumnIndex("sImageId"));
            int kind = cursor.getInt(cursor.getColumnIndex("kind"));
            float money = cursor.getFloat(cursor.getColumnIndex("money"));
            int year = cursor.getInt(cursor.getColumnIndex("year"));
            int month = cursor.getInt(cursor.getColumnIndex("month"));
            int day = cursor.getInt(cursor.getColumnIndex("day"));
            AccountBean accountBean = new AccountBean(id, typeName, sImageId, bz, money, time, year, month, day, kind);
            list.add(accountBean);
        }
        return list;
    }

== 模糊搜索这样来写:==

String sql = "select * from accounttb where beizhu like '%" + beizhu +"%'";

搜索页面布局文件:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:background="@color/grey_f3f3f3">
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="50dp">

        <ImageView
            android:id="@+id/search_iv_back"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:onClick="onClick"
            android:layout_marginLeft="10dp"
            android:src="@mipmap/it_back1"/>

        <EditText
            android:id="@+id/search_et"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_toRightOf="@id/search_iv_back"
            android:background="@drawable/dialog_btn_bg"
            android:layout_centerVertical="true"
            android:textSize="16sp"
            android:paddingTop="10dp"
            android:paddingBottom="10dp"
            android:paddingLeft="20dp"
            android:layout_marginLeft="10dp"
            android:hint
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值