RecyclerView 报Scrapped or attached views may not be recycled. as Scrap:false isAttached:true异常
来源:互联网 发布:自学办公自动化软件 编辑:程序博客网 时间:2024/04/28 17:32
最近在做项目中使用RecyclerView时会偶现以下异常:
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:3586) at android.support.v7.widget.RecyclerView$Recycler.quickRecycleScrapView(RecyclerView.java:3640) at android.support.v7.widget.RecyclerView$LayoutManager.removeAndRecycleScrapInt(RecyclerView.java:5492) at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:2086) at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:2237) at android.view.View.layout(View.java:15671) at android.view.ViewGroup.layout(ViewGroup.java:5038) at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1076) at android.view.View.layout(View.java:15671) at android.view.ViewGroup.layout(ViewGroup.java:5038) at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1076) at android.view.View.layout(View.java:15671) at android.view.ViewGroup.layout(ViewGroup.java:5038) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:579) at android.widget.FrameLayout.onLayout(FrameLayout.java:514) at android.view.View.layout(View.java:15671) at android.view.ViewGroup.layout(ViewGroup.java:5038) at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1703) at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1557) at android.widget.LinearLayout.onLayout(LinearLayout.java:1466) at android.view.View.layout(View.java:15671) at android.view.ViewGroup.layout(ViewGroup.java:5038) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:579) at android.widget.FrameLayout.onLayout(FrameLayout.java:514) at android.view.View.layout(View.java:15671) at android.view.ViewGroup.layout(ViewGroup.java:5038) at android.support.v4.widget.DrawerLayout.onLayout(DrawerLayout.java:907) at android.view.View.layout(View.java:15671) at android.view.ViewGroup.layout(ViewGroup.java:5038) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:579) at android.widget.FrameLayout.onLayout(FrameLayout.java:514) at android.view.View.layout(View.java:15671) at android.view.ViewGroup.layout(ViewGroup.java:5038) at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1703) at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1557) at android.widget.LinearLayout.onLayout(LinearLayout.java:1466) at android.view.View.layout(View.java:15671) at android.view.ViewGroup.layout(ViewGroup.java:5038) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:579) at android.widget.FrameLayout.onLayout(FrameLayout.java:514) at android.view.View.layout(View.java:15671) at android.view.ViewGroup.layout(ViewGroup.java:5038) at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1703) at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1557) at android.widget.LinearLayout.onLayout(LinearLayout.java:1466) at android.view.View.layout(View.java:15671) at android.view.ViewGroup.layout(ViewGroup.java:5038) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:579) at android.widget.FrameLayout.onLayout(FrameLayout.java:514) at android.view.View.layout(View.java:15671) at android.view.ViewGroup.layout(ViewGroup.java:5038) at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2086) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1843) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1061) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5885) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:767) at android.view.Choreographer.doCallbacks(Choreographer.java:580) at android.view.Choreographer.doFrame(Choreographer.java:550) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:753) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:135)
该异常是在RecyclerView.Recycler的recyclerViewHolderInernal方法中抛出:
/** * internal implementation checks if view is scrapped or attached and throws an exception * if so. * Public version un-scraps before calling recycle. */ void recycleViewHolderInternal(ViewHolder holder) { if (holder.isScrap() || holder.itemView.getParent() != null) { throw new IllegalArgumentException( "Scrapped or attached views may not be recycled. isScrap:" + holder.isScrap() + " isAttached:" + (holder.itemView.getParent() != null)); } ...省略... }
解决方法也不是很难,可以参考
http://stackoverflow.com/questions/26477660/recyclerview-crashes-when-scrapped-or-attached-views-may-not-be-recycled
1 0
- 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错误
- IllegalArgumentException: Scrapped or attached views may not be recycled. isScrap:false isAttached:t
- Scrapped or attached views may not be recycled
- Scrapped or attached views may not be recycled
- Scrapped or attached views may not be recycled
- 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
- The following types may not be used as proxies 异常
- 关于NHibernate异常The following types may not be used as proxies
- true or false
- The following types may not be used as proxies
- freemarker 异常 student.age does not evaluate to true/false
- will not be exported or published. Runtime ClassNotFoundExceptions may result
- tomcat安装ssl证书[推荐]
- 如何利用伪元素制造带三角的div
- linux内核sysfs详解
- 批量添加crontab 方法
- S3C2440开发板+RT3070无线网卡 基于hostapd+udhcpd+iptables实现softAP模式(路由器)
- RecyclerView 报Scrapped or attached views may not be recycled. as Scrap:false isAttached:true异常
- 短信工具类 SmsUtil
- hdu 2444 The Accomodation of Students【二分图染色+最大二分匹配数】
- 字符串的比较以及排序问题
- Android粒子雨效果之音量条显示
- 移动端,JS判断滑到页面底部上滑进行操作
- 归并排序
- JS 倒计时实现代码(时、分,秒)
- Python元类的理解