I am using recyclerview in my project. its orientation is horizontal. There are only 4 items in it. I want make it move in in circular form. What i mean is when user is on 4th item and swipes left the first item should be displayed. Now it just stops in the end.
Asked
Active
Viewed 766 times
-1
-
Can you provide us what you have done so far? – Federico Navarrete May 14 '18 at 11:01
-
You are looking for a circular recyclerview. https://stackoverflow.com/questions/31253555/how-do-i-create-a-circular-endless-recyclerview – Ricardo May 14 '18 at 11:02
-
look and visit this link -- https://stackoverflow.com/questions/37784868/how-to-create-closed-circular-recyclerview-with-custom-recycler-adapter – Prashant Jajal May 14 '18 at 11:07
-
Just a regular Recycler adapter @FedericoNavarrete – J DEO May 14 '18 at 11:08
-
1You must create a new custom layout manager. Check [this SO answer](https://stackoverflow.com/a/47491209/5392118) – Burak Cakir May 14 '18 at 11:10
1 Answers
0
One solution would be make item count of RecyclerView Integer.MAX_VALUE.
Update your RecyclerView Adapter as
@Override
public int getItemCount(){
return Integer.MAX_VALUE;
}
Then while getting item for position
MyClass getItem(int position) {
int positionInList = position % myList.size();
return myList.get(positionInList);
}
Then OnBindViewHolder ..
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
super.onBindViewHolder(holder, position);
MyClass item = getItem(position);
// use item as required here
}

Dhiraj Sharma
- 4,364
- 24
- 25