-1

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.

J DEO
  • 51
  • 1
  • 5

1 Answers1

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