IndexOutOfBoundsException与StaggeredGridLayoutManager的故事

参考资料

StaggeredGridLayoutManager报错IndexOutOfBoundsException
stackoverflow

bugly崩溃信息

bugly

解决方案

使用viewpager+4个fragment
每个fragment中为swiperefreshlayout+recyclervie
出现上述错误,最终错误原因不在StaggeredGridLayoutManager,而是viewpager的状态保存


解决方法:
viewpager.setOffscreenPageLimit(list.size() - 1);


作者:龙猫跑跑跑
链接:https://www.jianshu.com/p/7896f33e94fa
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

If your RecyclerView is in a Fragment and your Fragment is in ViewPager, and you didn't set viewpager.setOffscreenPageLimit(MAX_ITEM_SIZE), this crash will some times happen unexpectedl
I was suffering same crashes. I can't reproduce it, and don't know why it would happen till now. But after I set the off-screen page limit, this crash goes away.
Wish it helps.

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容