RecycleView Bug:java.lang.IndexOutOfBoundsException: Inconsistency detected.
今天使用RecyclerView时,上下两个RecyclerView,在实现下拉刷新时,报错:
java.lang.IndexOutOfBoundsException: Inconsistency detected.
Invalid view holder adapter positionViewHolder{56798b2 position=2 id=-1, oldPos=2, pLpos:-1 scrap [attachedScrap] tmpDetached 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));
RecycleView Bug:java.lang.IndexOutOfBoundsException: Inconsistency detected.的更多相关文章
- RecycleView错误: java.lang.IndexOutOfBoundsException: Inconsistency detected. Invalid view holder adapter positionViewHolder
1.错误 java.lang.IndexOutOfBoundsException: Inconsistency detected. Invalid view holder adapter positi ...
- 滑动RecyclerView时出现异常: java.lang.IndexOutOfBoundsException: Inconsistency detected. Invalid item position 6(offset:6).state:30
RecyclerView 存在的一个明显的 bug 一直没有修复: java.lang.IndexOutOfBoundsException: Inconsistency detected. Inval ...
- Recyclerview 出现 java.lang.IndexOutOfBoundsException: Inconsistency detected 异常
使用 RecyclerView 的时候报错 java.lang.IndexOutOfBoundsException: Inconsistency detected. Invalid view hold ...
- RecyclerView Bug:IndexOutOfBoundsException: Inconsistency detected. Invalid view holder adapter的解决方案(转)
转自:RecyclerView Bug:IndexOutOfBoundsException: Inconsistency detected. Invalid view holder adapter的解 ...
- Android中RecyclerView出现java.lang.IndexOutOfBoundsException
在RecyclerView更细数据时出现java.lang.IndexOutOfBoundsException: Inconsistency detected. Invalid view holder ...
- java.lang.IndexOutOfBoundsException: setSpan (35 ... 35) ends beyond length 28
/************************************************************************************* * java.lang.I ...
- 日志异常:java.lang.NoClassDefFoundError: Could not initialize class org.slf4j.impl.StaticLoggerBinder
今天启动开发的项目,碰到了一个日志上的bug:java.lang.NoClassDefFoundError: Could not initialize class org.slf4j.impl.Sta ...
- sparksql读取hive数据报错:java.lang.RuntimeException: serious problem
问题: Caused by: java.util.concurrent.ExecutionException: java.lang.IndexOutOfBoundsException: Index: ...
- maven发布到tomcat报错: Publishing failed Could not publish to the server. java.lang.IndexOutOfBoundsException
eclipse中将maven项目发布到tomcat报错时: Publishing failed Could not publish to the server. java.lang.IndexOutO ...
随机推荐
- 【Linux】- vi/vim
所有的 Unix Like 系统都会内建 vi 文书编辑器,其他的文书编辑器则不一定会存在. 但是目前我们使用比较多的是 vim 编辑器. vim 具有程序编辑的能力,可以主动的以字体颜色辨别语法的正 ...
- vim map nmap(转)
转自:http://blog.csdn.net/taoshengyang/article/details/6319106 有五种映射存在 - 用于普通模式: 输入命令时. - 用于可视模式: 可视 ...
- printf以及各种变种
int printf(char *format, [argument]); 其向终端(显示器.控制台等)输出字符 int fprintf(FILE*stream, const char*format, ...
- [CLR via C#]基元类型
一.什么是基元类型 某些数据类型如此常用,以至于许多编译器允许代码以简化的语法来操纵它们.例如,可以使用以下语法来分配一个整数: System.Int32 a = new System.Int32() ...
- 微信抢红包软件-android
微信红包不错的分析: 附带源码 并包含了源码 参考: Android中微信抢红包助手的实现 (1) https://www.jianshu.com/p/19ddd41aa349 (2) http:// ...
- [剑指Offer] 57.二叉树的下一个结点
题目描述 给定一个二叉树和其中的一个结点,请找出中序遍历顺序的下一个结点并且返回.注意,树中的结点不仅包含左右子结点,同时包含指向父结点的指针. /* struct TreeLinkNode { in ...
- 单选 name的值相同时候 就会产生互斥现象
- Python 文件对象和方法
Python文件对象和方法 1.打开和关闭文件 Python提供了必要的函数和方法进行默认情况下的文件基本操作,我们可以用file对象做大部分文件操作. open()方法 我们必须先用Python内置 ...
- 转 :hlda文献学习笔记
David M.BLEI nCR文献学习笔记(基本完成了) http://yhbys.blog.sohu.com/238343705.html 题目:The Nested Chinese Resta ...
- [luogu1654]OSU!
update 9.20:本篇题解已经被\(yyb\)证明是出锅的 这道题目最后的式子看上去是很简单的,不到10行就码完了,但是求式子的过程并没有那么简单. 很容易想到一种枚举思路: 因为每一段连续的1 ...