是否有可能在recyclerview加载项目时仅加载一次并且不重新加载滚动? [英] is it possible that when recyclerview load items just load one time and dont reload scrolling?
本文介绍了是否有可能在recyclerview加载项目时仅加载一次并且不重新加载滚动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否有可能当recyclerview加载项目仅加载一次并且不重新加载滚动时? 我想先加载所有数据,然后再将其加载到我的recyclerView.
is it possible that when recyclerview load items just load one time and dont reload scrolling? I want to load all data before loading it to my recyclerView.
推荐答案
您绝对可以做到这一点.
You can absolutely do that.
- (通过Web服务调用或通过任何其他方式)加载所有数据.
- 检索到数据后,将它们设置为
RecyclerView
的适配器并调用notifyDatasetChanged()
). - 通常使用
RecyclerView
(即,将数据对象绑定到onBindViewHolder()
中的视图.
- Load all the data (through a web service call or by any other means).
- When data are retrieved, set them to the
RecyclerView
's adapter and callnotifyDatasetChanged()
). - Use the
RecyclerView
normally (i.e. binding data objects to the views inonBindViewHolder()
.
这样,您将获得所需的内容(拥有所有数据,并且无需在用户滚动时加载更多内容),以及RecyclerView
的优点,它可以创建所需数量的视图.
This way you will get what you want (having all data and not needing to load more as the user scrolls) and the benefits of the RecyclerView
, that creates as many views as needed.
这篇关于是否有可能在recyclerview加载项目时仅加载一次并且不重新加载滚动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文