The specified child already has a parent. You must call removeView() on the child's parent first.
来源:互联网 发布:公司把lol端口紧了 编辑:程序博客网 时间:2024/04/29 05:47
java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
今天写代码要给AlertDialog加一个自定义的View 然后就报错了,报错是因为再一次触发加载布局view的时候由于在viewgroup里已经有了这个布局所以不能再一次加载,必须先要移除,经过分析发现了解决办法
一开始是这样写的
<span style="white-space:pre"></span>view = getLayoutInflater().from(MainActivity2.this).inflate(R.layout.numberpicker,null); AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity2.this); builder.setView(view);
后来这样写 就可以了
<span style="font-size:24px;"> </span><span style="font-size:14px;"> view = getLayoutInflater().from(MainActivity2.this).inflate(R.layout.numberpicker,null); ViewGroup vg=(ViewGroup)view.getParent(); AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity2.this); if(vg!=null){ vg.removeView(view); } builder.setView(view);</span>
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.
- hdu 2669 Romantic
- spring aop相关知识
- (大数据之flume)flume常用的几种配置
- Fragment
- Java内部类
- The specified child already has a parent. You must call removeView() on the child's parent first.
- PO-->OOP+AOP-->SOA软件开发思想演化
- linux下使用网络
- 解决: /opt/MATLAB/R2012a/sys/os/glnxa64/libstdc++.so.6: version `GLIBCXX_3.4.15' not found
- 概率导论学习心得
- android 源码编译
- MVC小结
- 笔记(const)
- MySQL: Fundamental control commands