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 ...
随机推荐
- IIS部署网部常用问题汇总
1.unrecognized attribute 'targetframework' A: 需要注册.net framework到iis.步骤如下: (1)'Start' -> 'CMD' (2 ...
- [STAThread] 作用
[STAThread]是一种线程模型,用在程序的入口方法上(在C#和VB.NET里是Main()方法),来指定当前线程的ApartmentState 是STA. [STAThread]是声明开始线程用 ...
- Python运算符与编码
阅读目录 while 循环 运算符 编码的问题 单位转换 整数 布尔值 while 循环 在生活中,我们遇到过循环的事情吧?比如循环听歌.在程序中,也是存才的,这就是流程控制语句 while 1.基本 ...
- 每个zone的low memory是怎么计算出来的
内核都是试图让活动页和不活动页的数量均衡 在分配内存时每次都会唤醒wakeup_swapd,这个函数会在 现在是不是已经没有全局的LRU表了?已经都变成per cgroup级别的LRU表了吗? ina ...
- 一日一句 SQL [持续更新] MySQL + Oracle
1 . group by 和 having字句: group by是根据列值对数据进行分组, having子句用于对分组的数据进行过滤. [ having 针对的对象是分好的组] eg: employ ...
- [洛谷P3975][TJOI2015]弦论
题目大意:求一个字符串的第$k$大字串,$t$表示长得一样位置不同的字串是否算多个 题解:$SAM$,先求出每个位置可以到达多少个字串($Right$数组),然后在转移图上$DP$,若$t=1$,初始 ...
- [洛谷P2447][SDOI2010]外星千足虫
题目大意:有$n$个数,每个数为$0$或$1$,给你其中一些关系,一个关系形如其中几个数的异或和是多少,问最少知道前几个关系就可以得出每个数是什么,并输出每个数 题解:异或方程组,和高斯消元差不多,就 ...
- bzoj3302&bzoj2447&bzoj2103(树的重心)
三倍的幸福! 暴力的做法就是枚举每一条边断开,选的两个点就是左右两棵树的重心. 可以发现找重心的时候一定是往权和大的子树找的,需要维护一个点的最大和次大子树,因为最大子树可能被割掉了,实际效率为O(N ...
- bzoj1014: [JSOI2008]火星人prefix(splay+hash+二分)
题目大意:一个字符串三个操作:①求两个后缀的LCP②插入一个字符③修改一个字符. 前几天刚学了hash+二分求lcp,就看到这题. 原来splay还能这么用?!原来splay模板这么好写?我以前写的s ...
- Codeforces Round #343 (Div. 2) B
B. Far Relative’s Problem time limit per test 2 seconds memory limit per test 256 megabytes input st ...