如何创建一个圆形(环形)RecyclerView [英] How to create a Circular (endless) RecyclerView
问题描述
我试图让我的RecyclerView环回我的列表的开始。我已搜查所有在互联网上,并已成功地检测到时,我已经达到了我的列表的末尾但我不能确定在哪里可以从这里出发。
这是我目前使用的检测列表的到底是什么(找到<一href=\"http://stackoverflow.com/questions/26543131/how-to-implement-endless-list-with-recyclerview\">here):
@覆盖
公共无效onScrolled(RecyclerView recyclerView,诠释DX,DY INT){ visibleItemCount = mLayoutManager.getChildCount();
totalItemCount = mLayoutManager.getItemCount();
pastVisiblesItems = mLayoutManager.findFirstVisibleItemPosition(); 如果(装载){
如果((visibleItemCount + pastVisiblesItems)&GT; = totalItemCount){
加载= FALSE;
Log.v(...,+ visibleItemCount);
}
}
}
当滚动到最后,我想的观点是可见的,而从列表的顶部显示用数据,或者当滚动到列表我会从该列表的底部显示数据的顶部。对>
例如:
结果
视图1
视图2
VIEW3
View4
View5
View5
视图1
视图2
VIEW3
View4
有没有使其无限的方式,但有一种方法来使它看起来像inifite。在您的适配器覆盖 getCount将()
方法返回的东西大如 Integer.MAX_VALUE的
和对的getItem()
和 getView()
法模分(%)由真实项目编号位置。
在结束在中间设置当前项目的东西。
I am trying to make my RecyclerView loop back to the start of my list. I have searched all over the internet and have managed to detect when I have reached the end of my list however I am unsure where to proceed from here.
This is what I am currently using to detect the end of the list (found here):
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
visibleItemCount = mLayoutManager.getChildCount();
totalItemCount = mLayoutManager.getItemCount();
pastVisiblesItems = mLayoutManager.findFirstVisibleItemPosition();
if (loading) {
if ( (visibleItemCount+pastVisiblesItems) >= totalItemCount) {
loading = false;
Log.v("...", ""+visibleItemCount);
}
}
}
When scrolled to the end, I would like to views to be visible while the displaying data from the top of the list or when scrolled to the top of the list I would display data from the bottom of the list.
For example:
View1
View2
View3
View4
View5
View5 View1 View2 View3 View4
There is no way of making it infinite, but there is a way to make it look like inifite. In your adapter override getCount()
method to return something big like Integer.MAX_VALUE
And on getItem()
and getView()
method modulo divide (%) position by real item number.
At the end set current item to something in a middle.
这篇关于如何创建一个圆形(环形)RecyclerView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!