VerticalGridFragment无尽滚动 [英] VerticalGridFragment Endless scroll

查看:99
本文介绍了VerticalGridFragment无尽滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建android电视应用程序,但是我不知道如何在 Verticalgridfragment 中实现无限滚动,我使用了 ArrayObjectAdapter ,有人可以帮助我吗?

I'm creating android tv app but I don't know how to implement endless scroll in Verticalgridfragment, i use ArrayObjectAdapter, can someone help me do that?

推荐答案

我很乐意为您提供大量的示例代码,但我不在我的工作电脑上.基本上,您将在 Browse / RowsFragment 中实现 onItemSelected 侦听器(它应该类似于 setOnItemViewSelectedListener()从您的片段中).

I'd love to give you a full answer with oodles of code samples but I'm not at my work computer. Basically you'll implement the onItemSelected listener in your Browse/RowsFragment (it should be something like setOnItemViewSelectedListener() from your fragment).

然后检查当前所选元素是否在,当下一页请求正在进行时,在您获取数据时将其删除.

Then you do a check to see if the currently selected element is within 5 or 10 or 15 elements from the end of the list. If it's within that threshold, then make the request for the next page of your list and call addAll() on your adapter when you get the next page. You can optionally show a "loading card" while the next page request is in flight and remove it when you get your data.

我的实现基于此开源项目-虽然还不够完善,但应该足够的代码示例以帮助您入门.

I based my implementation off of this open source project - while it's not perfect it should be enough of a code sample to get your started.

这篇关于VerticalGridFragment无尽滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆