简体   繁体   English

Android 中 ArrayList 的分页

[英]Pagination From ArrayList in Android

I have ArrayList in my Constant file like below我的常量文件中有 ArrayList,如下所示

public static ArrayList<ItemCategory> arrayListCategories = new ArrayList<>();

I am looking for display result with pagination so as mentioned here我期待与分页显示效果,从而提到这里

I have tried below code我试过下面的代码

ArrayList<ItemCategory> arraylistsub = (ArrayList<ItemCategory>) Constant.arrayListCategories.subList(0,10);
        adapterCat = new AdapterCat(arraylistsub);
        recyclerView.setAdapter(adapterCat);

But its getting error called但它的获取错误称为

java.lang.ClassCastException: java.util.ArrayList$SubList cannot be cast to java.util.ArrayList

I am not getting idea, whats wrong with it and how I can resolve it.我不明白,它有什么问题以及如何解决它。 Let me know if someone here can help me for same.让我知道这里是否有人可以帮助我。

Thanks!谢谢!

尝试这个

ArrayList<ItemCategory> arraylistsub = new ArrayList<>(Constant.arrayListCategories.subList(0,10));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM