RecyclerView开发中不常见bug解决
来源:互联网 发布:js文件什么样 编辑:程序博客网 时间:2024/05/21 06:55
java.lang.IndexOutOfBoundsException
Inconsistency detected. Invalid view holder adapter positionViewHolder{31b397f1 position=3 id=-1, oldPos=-1, pLpos:-1 no parent}
其实也不是什么解决方法,只是把这个异常捕获了,不让他奔溃了,这个问题的终极解决方案还是得让google去修复。
1、创建一个类LinearLayoutManagerWrapper继承LinearLayoutManager,重写onLayoutChildren方法
public class WrapContentLinearLayoutManager extends LinearLayoutManager { public WrapContentLinearLayoutManager(Context context) { super(context); } public WrapContentLinearLayoutManager(Context context, int orientation, boolean reverseLayout) { super(context, orientation, reverseLayout); } public WrapContentLinearLayoutManager(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); } @Override public void onLayoutChildren(RecyclerView.Recycler recycler, RecyclerView.State state) { try { super.onLayoutChildren(recycler, state); } catch (IndexOutOfBoundsException e) { e.printStackTrace(); } }}2、设置RecyclerView的布局管理为WrapContentLinearLayoutManager对象
mRecyclerView.setLayoutManager(new WrapContentLinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
0 0
- RecyclerView开发中不常见bug解决
- RecyclerView导入bug解决
- Android6.0中横向RecyclerView空白bug解决
- 开发中常见的bug(一)
- Android 开发中常见bug 总结
- iOS 开发中常见的BUG
- 常见css bug解决
- 移动web前端开发之常见bug解决
- ios开发常见bug
- aandroid 开发常见bug
- iOS开发常见bug
- ios开发常见bug
- Android开发 解决RecyclerView in SwipeRefreshLayout触发下拉刷新的bug
- 解决Android SwipeRefreshLayout & RecyclerView使用的Bug
- 解决Android SwipeRefreshLayout & RecyclerView使用的Bug
- Android开发中Scrollview嵌套recyclerview时,recyclerview不显示数据
- GWT 常见开发中遇到奇怪bug的解决办法
- 开发中常见的bug/及项目解说
- C语言获取无线连接状态(Linux)
- 第 15 & 16 章 Jenkins –Automated Deployment&Metrics and Trends
- Hibernate与MyBatis的比较
- 兼容iOS 10 资料整理笔记
- jQuery防止动画重复执行
- RecyclerView开发中不常见bug解决
- NetBSD mail.local Privilege Escalation
- 网页打印的简单实现 + window.print
- spark流数据处理:Spark Streaming的使用
- [Android]异步任务AsyncTask使用解析
- Linux_redis/phpredis
- PGM:图模型学习概述
- SQL的注入式攻击方式和避免方法
- 适配 iOS10 以及 Xcode8