Android MVVM框架使用(十二)记事本功能增强:视图类型、批量删除、搜索笔记

其次隐藏掉浮动按钮:

在这里插入图片描述

最后在页面底部增加一个布局,这个布局里面是删除和多选:

<LinearLayout

android:layout_width=“match_parent”

android:layout_height=“?attr/actionBarSize”

android:layout_alignParentBottom=“true”

android:background=“@color/white”

android:gravity=“center_vertical”

android:visibility=“@{isBatchDeletion ? View.VISIBLE : View.GONE}”>

<TextView

android:id=“@+id/tv_delete”

android:layout_width=“0dp”

android:layout_height=“wrap_content”

android:layout_weight=“1”

android:drawableTop=“@mipmap/ic_delete”

android:gravity=“center”

android:text=“删除”

android:textColor=“@color/black” />

<TextView

android:id=“@+id/tv_all_selected”

android:layout_width=“0dp”

android:layout_height=“wrap_content”

android:layout_weight=“1”

android:drawableTop=“@{isAllSelected ? ContextCompat.getDrawable(tvAllSelected.getContext(),R.mipmap.ic_all_selected) : ContextCompat.getDrawable(tvAllSelected.getContext(),R.mipmap.ic_all_select)}”

android:gravity=“center”

android:text=“@{isAllSelected ? 取消全选 : 全选}”

android:textColor=“@{isAllSelected ? @color/purple_500 : @color/black}” />

图标去我的源码中拿,添加位置如下图所示:

在这里插入图片描述

现在是页面修改完了,还有item的布局中也需要改动,打开item_notebook.xml,增加变量数据代码:

在这里插入图片描述

这里你会看到我把这个item的点击事件去掉了,这部分代码我将会挪到NoteActivity中,因此这里要修改一下item_notebook.xml中的代码:

<?xml version="1.0" encoding="utf-8"?>

<variable

name=“notebook”

type=“com.llw.mvvm.db.bean.Notebook” />

<variable

name=“isBatchDeletion”

type=“Boolean” />

<RelativeLayout

android:layout_width=“match_parent”

android:layout_height=“wrap_content”

android:layout_margin=“@dimen/dp_4”

android:background=“@drawable/shape_bg_white_radius_12”

android:foreground=“?attr/selectableItemBackground”

android:padding=“12dp”>

<TextView

android:id=“@+id/tv_title”

android:layout_width=“match_parent”

android:layout_height=“wrap_content”

android:layout_toStartOf=“@+id/iv_check”

android:ellipsize=“end”

android:singleLine=“true”

android:text=“@{notebook.title}”

android:textColor=“@color/black”

android:textSize=“16sp” />

<TextView

android:id=“@+id/tv_content”

android:layout_width=“match_parent”

android:layout_height=“wrap_content”

android:layout_below=“@+id/tv_title”

android:layout_marginTop=“4dp”

android:layout_toStartOf=“@+id/iv_check”

android:ellipsize=“end”

android:maxLines=“3”

android:text=“@{notebook.content}”

android:textSize=“14sp” />

<ImageView

android:id=“@+id/iv_check”

android:layout_width=“24dp”

android:layout_height=“24dp”

android:layout_alignParentEnd=“true”

android:layout_centerVertical=“true”

android:layout_marginStart=“6dp”

android:src=“@{notebook.select ? Context

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值