java.lang.IllegalArgumentException: Scrapped or attached views may not be recycled. isScrap:false is
2017-05-23 15:39
736 查看
报错日志,调用RecyclerView时偶尔报错。
这个报错现象是因为我先把绑定在RecyclerView的数据源的数据清空再调用请求获取新数据导致的。我先清空了已有的数据,然后再获取网络接口的数据,而从清空数据到获取到数据的这段时间里,List中的数据是不存在的,所以给了RecyclerView要回收Item,但是View没有被回收的假象(此时并没有执行notifyDataSetChanged()方法),因此程序报错。
特此记录下。
java.lang.IllegalArgumentException: Scrapped or attached views may not be recycled. isScrap:false isAttached:true at android.support.v7.widget.RecyclerView$Recycler.recycleViewHolderInternal(RecyclerView.java:5659) at android.support.v7.widget.RecyclerView$Recycler.recycleView(RecyclerView.java:5603) at android.support.v7.widget.GapWorker.prefetchPositionWithDeadline(GapWorker.java:277) at android.support.v7.widget.GapWorker.flushTaskWithDeadline(GapWorker.java:324) at android.support.v7.widget.GapWorker.flushTasksWithDeadline(GapWorker.java:337) at android.support.v7.widget.GapWorker.prefetch(GapWorker.java:344) at android.support.v7.widget.GapWorker.run(GapWorker.java:370) at android.os.Handler.handleCallback(Handler.java:743) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:150) at android.app.ActivityThread.main(ActivityThread.java:5665) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:822) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:712)
这个报错现象是因为我先把绑定在RecyclerView的数据源的数据清空再调用请求获取新数据导致的。我先清空了已有的数据,然后再获取网络接口的数据,而从清空数据到获取到数据的这段时间里,List中的数据是不存在的,所以给了RecyclerView要回收Item,但是View没有被回收的假象(此时并没有执行notifyDataSetChanged()方法),因此程序报错。
特此记录下。
相关文章推荐
- java.lang.IllegalArgumentException: Scrapped or attached views may not be recycled. isScrap:false is
- java.lang.IllegalArgumentException: Scrapped or attached views may not be recycled. isScrap:false is
- java.lang.IllegalArgumentException: Scrapped or attached views may not be recycled. isScrap:false is
- java.lang.IllegalArgumentException: Scrapped or attached views may not be recycled. isScrap:false is
- java.lang.IllegalArgumentException: Scrapped or attached views may not be recycled. isScrap:false is
- IllegalArgumentException: Scrapped or attached views may not be recycled. isScrap:false isAttached:t
- java.lang.IllegalArgumentException: Scrapped or attached views may not be recycled.
- RecyclerView 报Scrapped or attached views may not be recycled. as Scrap:false isAttached:true异常
- Scrapped or attached views may not be recycled. isScrap:false isAttached:true异常
- Scrapped or attached views may not be recycled. isScrap:false isAttached:true错误
- Tomcat的异常 之 java.lang.IllegalArgumentException: Document base xxx does not exist or is not a readab
- java.lang.IllegalArgumentException: Document base D:\myspace\MyProj\WebContent does not exist or is
- Tomcat的异常 之 java.lang.IllegalArgumentException: Document base *** does not exist or is not a readable
- java.lang.IllegalArgumentException: Document base XXXXX does not exist or is not a readable directory
- java.lang.IllegalArgumentException:Document base ……does not exist or is not a readable directory错误的解决方案
- 关于网络请求的一个异常bug(java.lang.IllegalArgumentException: Host name may not be null)
- Tomcat的异常 之 java.lang.IllegalArgumentException: Document base *** does not exist or is not a readabl
- tomcat的java.lang.IllegalArgumentException:Document base *** does not exist or is not a readable
- java.lang.IllegalArgumentException: Window type can not be changed after the window is added.
- Tomcat的异常 之 java.lang.IllegalArgumentException: Document base *** does not exist or is not a readable