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 ...
随机推荐
- 【.NET】- async await 异步编程
为什么需要异步,异步对可能起阻止作用的活动(例如,应用程序访问 Web 时)至关重要. 对 Web 资源的访问有时很慢或会延迟. 如果此类活动在同步过程中受阻,则整个应用程序必须等待. 在异步过程中, ...
- 抽象类 C#
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...
- 【Maven】Snapshot和Release版本的区别
Snapshot版本代表不稳定.尚处于开发中的版本,快照版本. Release版本则代表稳定的版本,发行版本. 什么时候用Snapshot版本? 依赖库中的jar正处于开发的阶段,会被经常被更新,这种 ...
- TCP/IP三次握手与四次握手
原文地址 http://blog.csdn.net/whuslei/article/details/6667471 http://blog.csdn.net/wo2niliye/article/det ...
- 【bzoj4500】矩阵 带权并查集
题目描述 有一个n*m的矩阵,初始每个格子的权值都为0,可以对矩阵执行两种操作: 1. 选择一行, 该行每个格子的权值加1或减1. 2. 选择一列, 该列每个格子的权值加1或减1. 现在有K个限制,每 ...
- C语言调用Intel处理器CPUID指令的实例
C语言调用Intel处理器CPUID指令的实例 来源 https://blog.csdn.net/subfate/article/details/50789905 在Linux环境下,使用C语言内嵌汇 ...
- 【原创】宿主机远程登录虚拟机(windows server 2003系统)
转载请注明,谢谢合作 1.虚拟机网络设置为 “桥接模式”如图 2.系统装好并登陆后 右键点击我的电脑,点击属性,然后在弹出来的选择框中勾选远程桌面-->启用这台计算机的远程桌面 然后点添加-- ...
- 卡特兰数(Catalan Number) 学习笔记
一.三个简单的问题 1.给定一串长为2n的01序列,其中0和1的数量相等,满足任意前缀中0的个数不少于1的个数,求序列的个数 2.给出一串长为n的序列,按顺序将他们进栈,随意出栈,求最后进出栈的方案 ...
- HDOJ.1070 Milk(贪心)
Milk 点我挑战题目 题意分析 每组测试数据给出一系列牛奶商品,分别是牛奶的品牌,价格,以及体积.在读取数据的时候,体积在200以下的牛奶直接忽略掉.并且每天要喝200ML的牛奶.但是无论牛奶体积有 ...
- 【单调队列】【P1714】 切蛋糕
传送门 Description 今天是小Z的生日,同学们为他带来了一块蛋糕.这块蛋糕是一个长方体,被用不同色彩分成了N个相同的小块,每小块都有对应的幸运值. 小Z作为寿星,自然希望吃到的第一块蛋糕的幸 ...