[英]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.