如何使用分页库在回收者视图中添加日期分隔符? [英] How to add date separators in recycler view using Paging Library?
本文介绍了如何使用分页库在回收者视图中添加日期分隔符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
经过大量搜索,我知道使用常规适配器是可行的,但是我不知道如何使用Paging Library来实现.我不需要代码只是一个线索.
After a lot of searching, I know its possible with regular adapter, but I have no idea how to do it using Paging Library. I don`t need code just a clue.
示例
推荐答案
要添加分隔符,您实际上有2个选择:
To add separators, you essentially have 2 options:
- 基于视图,您将分隔符作为项目"明确包含在列表中,并为这些分隔符定义了新的视图类型.允许列表重新使用分隔符视图,但意味着定义数据时需要考虑分隔符.
- 基于数据的每个项目实际上都有一个分隔符视图,但仅显示在特定项目上.根据某些条件,您可以在绑定视图持有者的同时显示或隐藏它.
对于分页库,仅选项2是可行的,因为它仅部分加载数据,并且插入分隔符变得更加复杂.您只需找出一种方法来检查x
项是否与x-1
项不同,并根据结果在视图中显示/隐藏日期部分.
For the paging library only option 2 is viable since it only partially loads the data and inserting the separators becomes much more complicated. You will simply need to figure out a way to check if item x
is a different day than item x-1
and show/hide the date section in the view depending on the result.
这篇关于如何使用分页库在回收者视图中添加日期分隔符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文