VerticalGridFragment Endless scroll

最后都变了- 提交于 2021-01-27 20:39:13

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/41310820/verticalgridfragment-endless-scroll

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!