美文网首页
IndexOutOfBoundsException与Stagge

IndexOutOfBoundsException与Stagge

作者: 小呀么小黄鸡 | 来源:发表于2022-06-10 11:00 被阅读0次

参考资料

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.

相关文章

网友评论

      本文标题:IndexOutOfBoundsException与Stagge

      本文链接:https://www.haomeiwen.com/subject/kuzvmrtx.html