循环回收器视图 [英] Circular RecyclerView

查看:78
本文介绍了循环回收器视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

比方说,我们下面是一组视图:

Let's say we the following set of item Views:

View1 -> View2 -> View3 -> ... -> View(n-1) -> View(n)

在经典的RecyclerView上,View1位于第一个位置,View(n)位于最后一个位置.现在,我想做一个圆形,所以在最后一个位置之后,我们再次滚动到第一个位置:

On classic RecyclerView, View1 would be on first position and View(n) on last. Now I would like to make that circular so after last position we scroll again to first position:

View1 -> View2 -> View3 -> ... -> View(n-1) -> View(n) -> View1 -> View2 -> ...

乍看起来,这看起来很简单,但是我不确定在View(n)之后如何完成该重置"操作.任何建议都会非常有帮助.谢谢.

This at first look seems simple to make but I am not sure how to accomplish that "reset" after View(n). Any advice would be really helpful. Thank you.

推荐答案

有关ListView,请参考此解决方案.您可以编写包含Integer.MAX_VALUE个项目的RecyclerView.Adapter.唯一的区别是RecyclerView不再具有setSelectionFromTop方法.相反,您应该致电

Please refer to this solution for ListView. You may write a RecyclerView.Adapter that has Integer.MAX_VALUE items. The only difference is that RecyclerView no longer has setSelectionFromTop method. Instead you should call

recyclerView.getLayoutManager().scrollToPosition(recyclerAdapter.MIDDLE);

首先将recyclerView滚动到中间.

in order to scroll the recyclerView to the middle at first.

这篇关于循环回收器视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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