RecyclerView刷新异常java.lang.IndexOutOfBoundsException
来源:互联网 发布:寻找客源的软件 编辑:程序博客网 时间:2024/06/06 03:18
使用RecyclerView下拉刷新发现异常崩溃,异常如下:
java.lang.IndexOutOfBoundsException: Inconsistency detected. Invalid view holder adapter positionViewHolder{13e04da position=8 id=-1, oldPos=-1, pLpos:-1 no parent} at android.support.v7.widget.RecyclerView$Recycler.validateViewHolderForOffsetPosition(RecyclerView.java:5297) at android.support.v7.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:5479) at android.support.v7.widget.GapWorker.prefetchPositionWithDeadline(GapWorker.java:282) at android.support.v7.widget.GapWorker.flushTaskWithDeadline(GapWorker.java:336) at android.support.v7.widget.GapWorker.flushTasksWithDeadline(GapWorker.java:349) at android.support.v7.widget.GapWorker.prefetch(GapWorker.java:356) at android.support.v7.widget.GapWorker.run(GapWorker.java:387) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5417) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
问题分析
网上搜索解决方案大多说是adapter的list刷新数据后没有调用notirfyDataSetChanged()通知adapter,检查代码后发现果然有一处
adapter.getData().clear();
解决方案
更新list数据后及时调用notifyDataSetChanged方法
adapter.getData().clear();adapter.notifyDataSetChanged();
阅读全文
0 0
- RecyclerView刷新异常java.lang.IndexOutOfBoundsException
- RecyclerView:java.lang.IndexOutOfBoundsException: Invalid item position
- 怎么会抛出java.lang.IndexOutOfBoundsException这个异常
- 怎么会抛出java.lang.IndexOutOfBoundsException这个异常
- RecyclerView 出现了 IndexOutOfBoundsException 异常
- java.lang.IndexOutOfBoundsException
- java.lang.IndexOutOfBoundsException错误
- ViewPager数组角标越界异常 java.lang.IndexOutOfBoundsException
- 项目____java.lang.IndexOutOfBoundsException异常
- RecyclerView 的IndexOutOfBoundsException: Inconsistency detected异常解决办法
- RecyclerView系列(4)—XRexyclerView的坑,java.lang.IndexOutOfBoundsException: Inconsistency detected
- java.lang.IndexOutOfBoundsException 错误解决
- java.lang.IndexOutOfBoundsException,数组越界
- java.lang.IndexOutOfBoundsException 错误解决
- java.lang.IndexOutOfBoundsException 错误解决
- java.lang.IndexOutOfBoundsException 错误解决
- Android onTouchEvent java.lang.IndexOutOfBoundsException
- java.lang.IndexOutOfBoundsException: Inconsistency detected.
- Android Studio上方便使用butterknife注解框架的偷懒插件Android Butterknife Zelezny
- js页面循环input,checked赋值
- hive的行转列,列转行
- FFmpeg-3.3.1移植到Android平台(Mac编译)
- nanddump读出nandflash包括坏块
- RecyclerView刷新异常java.lang.IndexOutOfBoundsException
- 内联函数
- 解决Eclipse SVN文件冲突详解
- 事物管理
- 禁用控件回车事件监听事件
- 本地YUM源制作
- C#开发笔记: 字体对话框,颜色对话框案例
- Webmagic爬虫--①初入门
- java String对象详细说明