RecycleView异常Added View has RecyclerView as parent but view is not a real child. Unfiltered index:0
来源:互联网 发布:看得很湿的黄文 知乎 编辑:程序博客网 时间:2024/05/16 12:35
Android RecycleView 异常
java.lang.IllegalStateException:Added View has RecyclerView as parent but view is not a real child. Unfiltered index:0
log日志:
07-16 14:54:12.075: E/AndroidRuntime(20475): java.lang.IllegalStateException:Added View has RecyclerView as parent but view is not a real child. Unfilteredindex:007-16 14:54:12.075: E/AndroidRuntime(20475): atandroid.support.v7.widget.RecyclerView$LayoutManager.addViewInt(RecyclerView.java:6720)07-16 14:54:12.075: E/AndroidRuntime(20475): atandroid.support.v7.widget.RecyclerView$LayoutManager.addView(RecyclerView.java:6686)07-16 14:54:12.075: E/AndroidRuntime(20475): atandroid.support.v7.widget.RecyclerView$LayoutManager.addView(RecyclerView.java:6674)
在使用RecycleView中 偶尔出现了该异常
追踪该异常发现出自
android.support.v7.widget.RecyclerView$LayoutManager.addViewInt(RecyclerView.java:6720)
if (child.getParent() == mRecyclerView) { // it was not a scrap but a valid child // ensure in correct position int currentIndex = mChildHelper.indexOfChild(child); if (index == -1) { index = mChildHelper.getChildCount(); } if (currentIndex == -1) { throw new IllegalStateException("Added View has RecyclerView as parent but" + " view is not a real child. Unfiltered index:" + mRecyclerView.indexOfChild(child)); } if (currentIndex != index) { mRecyclerView.mLayout.moveView(currentIndex, index); } }
发现异常原因是 :
recycleView同时进行 "下拉刷新" 和 "加载更多" 而产生冲突 .
recycleView 执行异步的"加载更多"操作后 , 当调用recycleView 的addviewInt方法填充数据时, 发现列表已经被"下拉刷新"删除了. 找不到常规的child.
解决异常:
禁止 RecycleView "下拉刷新" 和 "加载更多" 同时执行 .
同一时间只允许用户使用一种动作 (即: 刷新不加载 加载不刷新 )
// ┏┓ ┏┓//┏┛┻━━━┛┻┓//┃ ┃//┃ ━ ┃//┃ ┳┛ ┗┳ ┃//┃ ┃//┃ ┻ ┃//┃ ┃//┗━┓ ┏━┛// ┃ ┃ 神兽保佑// ┃ ┃ 代码无BUG!// ┃ ┗━━━┓// ┃ ┣┓// ┃ ┏┛// ┗┓┓┏━┳┓┏┛// ┃┫┫ ┃┫┫// ┗┻┛ ┗┻┛
谢谢
0 0
- RecycleView异常Added View has RecyclerView as parent but view is not a real child. Unfiltered index:0
- Added View has RecyclerView as parent but view is not a real child. Unfiltered index:0
- RecyclerView 的坑 1 Added View has RecyclerView as parent but view is not a real child. Unfiltered in
- error:Parent view is not a TextView
- Parent view is not a TextViewd的解决办法
- RecyclerView The specified child already has a parent
- AlertDialog异常The specified child already has a parent. ..解决方法
- 实习杂记(22)being added, but it already has a parent
- 关于addView方法的使用--Exception:the special child alread has a parent,please call remove view
- 关于向父view添加相同的view问题!The specified child already has a parent. You must call removeView() on the chil
- 关于RecyclerView的java.lang.IllegalStateException: The specified child already has a parent. You must c
- RecyclerView The specified child already has a parent. You must call removeView() on the child's pa
- The specified child already has a parent.
- The specified child already has a parent
- Teh specified child already has a parent
- The specified child already has a parent
- The specified child already has a parent
- Android异常分析之 java.lang.IllegalStateException:the specified child already has a parent.
- [区间dp] lightoj 1422 Halloween Costumes
- iOS 侧滑栏实现的放大和缩小
- Android提升进入界面的速度
- iOS 【使用Xcode和Instruments调试解决iOS内存泄露】
- Android Studio升级过程中可能出现的错误
- RecycleView异常Added View has RecyclerView as parent but view is not a real child. Unfiltered index:0
- 个人收集即时通讯方面在资料以便日后查阅
- 代码修养第二堂
- 我的Linux菜鸟之路1
- ps软件下载、安装及破解
- Ojbect对象的所有字段的表示方法
- HTML&CSS基础学习笔记1.13-有序列表及列表嵌套
- JAVA_时间计时器
- kafka集群搭建和使用Java写kafka生产者消费者