The specified child already has a parent. You must call removeView() on the child's parent first
来源:互联网 发布:森海塞尔淘宝旗舰店 编辑:程序博客网 时间:2024/05/16 06:25
最近公司新框架写布局全用代码实现不能用xml,写着写着运行一下发现没有布局显示。后发现是出现异常了,异常如下:
java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.//看字面意思是子View已经存在于父View,你必须先调用该子View的父View的removeView()方法
解决办法:
//在addView之前加入如下代码 ViewGroup parentViewGroup = (ViewGroup) 父View.getParent(); if (parentViewGroup != null) { parentViewGroup.removeAllViews(); } //之后就可以add子view了 父View.addView(子View1); 父View.addView(子View2); 父View.addView(子View3);
阅读全文
0 0
- The specified child already has a parent. You must call removeView() on the child's parent first.
- 二、The specified child already has a parent. You must call removeView() on the child's parent first.
- The specified child already has a parent. You must call removeView() on the child's parent first
- The specified child already has a parent. You must call removeView() on the child's parent first
- The specified child already has a parent. You must call removeView() on the child's parent first.
- The specified child already has a parent. You must call removeView() on the child's parent first.
- The specified child already has a parent. You must call removeView() on the child's parent first
- The specified child already has a parent. You must call removeView() on the child's parent first.
- 总是报The specified child already has a parent. You must call removeView() on the child's parent first.
- The specified child already has a parent. You must call removeView() on the child's parent first.解决办
- The specified child already has a parent. You must call removeView() on the child's parent first.
- The specified child already has a parent. You must call removeView() on the child's parent first.
- The specified child already has a parent. You must call removeView() on the child's parent first.
- The specified child already has a parent. You must call removeView() on the child's parent first
- The specified child already has a parent. You must call removeView() on the child's parent first.问解决
- The specified child already has a parent. You must call removeView() on the child's parent first.
- The specified child already has a parent. You must call removeView() on the child's parent first.
- The specified child already has a parent. You must call removeView() on the child's parent first.
- [转]《TCP/IP路由技术(第一卷)(第二版)》一1.3 IPv4 地 址
- PHP html 转换成PDF wkhtmltopdf HTML 转换成 PDF (JAVA C#都适用)
- JS判断客户端是手机还是PC的代码
- ingress-TLS
- sublime配置python
- The specified child already has a parent. You must call removeView() on the child's parent first
- UVA
- 文章标题
- php入门到精通精典案例教程
- 批量修改文件名
- WOJ1004-Noah's Ark
- Android -this,super关键字
- 剑指offer(八)跳台阶
- c语言构造素数表