简体   繁体   English

如何在不使用recyclerview中的库的情况下从服务器分页数据?

[英]How to paginate data from server without using library in recyclerview?

I have RecyclerView with CardView Adapter.我有带有 CardView 适配器的 RecyclerView。 I want to fetch data from url with several pages.我想从包含多个页面的 url 中获取数据。 How do I paginate data?如何对数据进行分页?

When the user is done with the first page I want a progressbar at the bottom of the page(Like Facebook app).当用户完成第一页时,我希望页面底部有一个进度条(如 Facebook 应用程序)。 I have to do this without using any libraries.我必须在不使用任何库的情况下执行此操作。 Does anyone have a solution for this?有没有人对此有解决方案?

PS : I dont have any url for pagination. PS:我没有任何分页网址。 Please send url too (I am just a beginner.Please be specific while explaining)也请发个网址(我只是初学者,解释的时候请具体一点)

Essentially what you need to do is detect the point at which the user has scrolled far enough that you need to get the next bit of data.本质上,您需要做的是检测用户滚动到足够远以获取下一位数据的点。 In order to do that you'll have to extend RecyclerView's OnScrollListener and override the OnScrolled method.为此,您必须扩展 RecyclerView 的 OnScrollListener 并覆盖 OnScrolled 方法。

You can check out the code and detailed solution with explanations about how to do this for different layout managers here: https://guides.codepath.com/android/Endless-Scrolling-with-AdapterViews-and-RecyclerView您可以在此处查看代码和详细解决方案以及有关如何针对不同布局管理器执行此操作的说明: https : //guides.codepath.com/android/Endless-Scrolling-with-AdapterViews-and-RecyclerView

As far as your requirement of a URL that you can use to test pagination, I'd suggest something like TMDB.至于您对可用于测试分页的 URL 的要求,我建议使用 TMDB 之类的东西。 The full documentation is available here: https://developers.themoviedb.org/3/getting-started完整文档可在此处获得: https : //developers.themoviedb.org/3/getting-started

You'll have to sign up for an API key.您必须注册一个 API 密钥。 You could start with a simple endpoint like api.themoviedb.org/3/movie/popular?api_key=<your api key here>&page=<page-number>你可以从一个简单的端点开始,比如api.themoviedb.org/3/movie/popular?api_key=<your api key here>&page=<page-number>

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

相关问题 如何使用 ROOM 库将数千条记录从本地数据库加载到 recyclerview 而不阻塞 UI - How to load thousands of records from local database to recyclerview without blocking UI using ROOM library 如何在不点击的情况下从 recyclerview 获取数据 - How to fetch data from recyclerview without click 我使用 Retrofit 库从数据库中获取数据到 recyclerview - iam using Retrofit library to fetch data from Database to recyclerview 我们如何在Android的Firebase实时数据库中对RecyclerView进行分页? - How Can We Paginate RecyclerView From Firebase Realtime Database On Android? 如何用两个列表对recyclerview进行分页 - How to paginate a recyclerview with two lists 如何在 android 中使用 recyclerview 显示来自 web 服务器的 JSON 格式数据 - How to display JSON format data from web server using recyclerview in android 如何使用 Room 和 RxJava 对数据进行分页? - how to paginate data using Room and RxJava? 从服务器提取数据后如何更新recyclerview? - how to update recyclerview after pulling data from server? 如何从android中recyclerview下面的服务器中获取数据 - How to fetch data from server below recyclerview in android 如何修复分页以在 RecyclerView 中从服务器加载更多数据? - How to fix pagination to load more data from server in RecyclerView?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM