简体   繁体   English

Android Recycler View:如何在滚动Recycler视图时停止加载图像并仅在滚动停止时才开始加载图像?

[英]Android Recycler View: How to stop loading of images when recycler view is scrolling and start loading only when scroll is stopped?

如何在回收站视图滚动时停止加载图像并仅在滚动停止时才开始加载?

A common application feature is to load automatically more items as the user scrolls through the items (aka infinite scroll). 一个常见的应用程序功能是在用户滚动浏览项目时自动加载更多项目(又称无限滚动)。 This is done by triggering a request for more data once the user crosses a threshold of remaining items before they've hit the end. 这是通过在用户超过剩余项目的阈值之前触发对更多数据的请求来完成的。

The approaches for ListView, GridView and RecyclerView (the successor to ListView) are documented here. 此处介绍了ListView,GridView和RecyclerView(ListView的后继者)的方法。 Both are similar in code except that the LayoutManager in the RecyclerView needs to be passed in to provide the necessary information to implement infinite scrolling. 两者的代码相似,不同之处在于,需要传递RecyclerView中的LayoutManager来提供实现无限滚动所需的信息。

Follow this link for more implementation details: 点击此链接以获取更多实施细节:

https://guides.codepath.com/android/Endless-Scrolling-with-AdapterViews-and-RecyclerView https://guides.codepath.com/android/Endless-Scrolling-with-AdapterViews-and-RecyclerView

The question is slightly unclear, but I'm going to assume that you are talking about loading images into an imageview in recyclerview/listview items. 这个问题还不清楚,但是我将假设您正在谈论将图像加载到recyclerview / listview项目中的imageview中。

Answer: Don't do it by hand. 答:不要用手做。 Use a library (like Glide ) to load the images for you. 使用一个库(如Glide )为您加载图像。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM