使用RecyclerView的两个非传统型崩溃

当在Android应用中使用RecyclerView时,可能会遇到两种非典型崩溃:1. Scraped or attached views may not be recycled,这通常与android:animateLayoutChanges和notifyDataSetChanged()的使用有关;2. Called attach on a child which is not detached。解决方案包括确保在更新列表前避免清空数据,或者自定义LayoutManager以捕获并处理异常。
摘要由CSDN通过智能技术生成
1. Scrapped or attached views may not be recycled. isScrap:false isAttached:true

崩溃场景 : 一个普通的RecyclerView列表,点击某个item进入详情页,然后返回时崩溃(bug日志如下).发现比较难寻找到具体原因,于是搜索了大谷歌爸爸.

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 a
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值