How to limit a table list to 10 and display the following 10 items by clicking More

advertisements

I am adding all the items in arrayList, now I want to display only 10 items in my recycler view and click of more 10 more and so on. I want to use same arrayList.


you can handle it by yourself in getCount() method.
you can put a integer in your adapter class and by each click on more button increase it 1.

int num = 1;

on more button click:

if((adapter.num)*10 < arrayList.size())
   adapter.num = adapter.num +1;

and in getCount() method:

 @Override
public int getCount() {
    if(num*10 > arrayList.size()){
        return arrayList.size();
    }else{
       return num*10;
    }
}