android 筛选功能,Android 一个RecyclerView实现筛选列表

效果图

b28bcfdbdca1

choice.gif

简介

如上图展示的内容,筛选条件的功能很常见,一般情况如果条件很多,那么布局文件就会写的很复杂,这篇文章可以提供一个简洁的方案,布局文件只用一个RecyclerView就可以了。当然,处理逻辑可能要少费点功夫,不过这些逻辑可以复用,如果有多个地方用到就省很多事了。

代码分析

先看看Bean类的处理:

数据中有几个必须要添加的属性

type:用于区分是标题item还是内容item,标题item也可以分很多类。

choice:标记item是否选中

multiChoice:这一类型标签是不是多选

allChoice:标签item是不是全选按钮(根据需求调整)

public class GridItemBean {

/**

* type:

* 标题item 自定义

* 内容item 默认为0

*/

private int type;

/**

* 标题(标题item)

*/

private String title;

private String id;

private String name;

/**

* 内容item 是否选择(内容item)

*/

private boolean choice;

/**

* 是否是多选(标题item)

*/

private boolean multiChoice;

/**

* 是否是全选按钮(内容item)

*/

private boolean allChoice;

public GridItemBean(int type, String title) {

this.type = type;

this.title = title;

}

public GridItemBean(int type, String title, boolean multiChoice) {

this.type = type;

this.title = title;

this.multiChoice = multiChoice;

}

public GridItemBean(String id, String name) {

this.id = id;

this.name = name;

}

public GridItemBean(String id, String name, boolean allChoice) {

this.id = id;

this.name = name;

this.allChoice = allChoice;

}

public int getType() {

return type;

}

public void setType(int type) {

this.type = type;

}

public String getId() {

return id;

}

public void setId(String id) {

this.id = id;

}

public String getTitle() {

return title;

}

public void setTitle(String title) {

this.title = title;

}

public String getName() {

return name;

}

public void setName(String name) {

this.name =

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值