extends:http://stackoverflow.com/questions/6526874/call-removeview-on-the-childs-parent-first

Exception:

  1. java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
  2. at android.view.ViewGroup.addViewInner(ViewGroup.java:1976)
  3. at android.view.ViewGroup.addView(ViewGroup.java:1871)
  4. at android.view.ViewGroup.addView(ViewGroup.java:1828)
  5. at android.view.ViewGroup.addView(ViewGroup.java:1808)
  1. Solution:
  2.  
  3. ((ViewGroup)scrollChildLayout.getParent()).removeView(scrollChildLayout);
  4.  
  5. Use the child element to get a reference to the parent. Cast the parent to a ViewGroup so that you get access to the removeView method and use that.
  1.    LinearLayout layout = initLayout();
  2. for (int i = 0; i < items.size(); i++) {
  3. View view = items.get(i);
  4. ((ViewGroup) view.getParent()).removeView(view);
  5. layout.addView(view, lpLabel);
  6. }
  7. mLayout.addView(layout);

Call removeView() on the child's parent first的更多相关文章

  1. java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.

    在ViewPager中,用Fragment显示页面时,报错: java.lang.IllegalStateException: The specified child already has a pa ...

  2. android 异常信息The specified child already has a parent. You must call removeView() on the child's parent first. 的处理方法

    [Android异常信息]: The specified child already has a parent. You must call removeView() on the child's p ...

  3. 【Android异常】The specified child already has a parent. You must call removeView() on the child's parent first.

    错误信息: Caused by: java.lang.IllegalStateException: The specified child already has a parent. You must ...

  4. 替换Fragment 报错 The specified child already has a parent. You must call removeView() on the child's parent first.

    在将一个fragment替换到一个frameLayout的时候报错: code: transaction.replace(R.id.fragment_container, fragment2); 错误 ...

  5. Android-The specified child already has a parent. You must call removeView() on the child's parent first.

    这个问题搞了我半天了,网上有很多人说需要找到该控件的parent后,让该parent 先remove需要添加的控件,然后在添加,如: if (view != null) { ViewGroup par ...

  6. Fragment+FragmentActivity出现The specified child already has a parent. You must call removeView() on the child's parent first.

    这个异常是出现在Fragment中的onCreateView方法中初始化布局时发生的. View view = inflater.inflate(R.layout.fragment3_layout, ...

  7. Child <- many-to-one ->Parent

    网上找到个描述的很精妙的例子 Child   <-   many-to-one   ->Parent         class   Child   {         private   ...

  8. Child extends Parent,可以得到什么?

    如果有Child extends Parent 1.子类可以调用父类无参的构造函数,子类的有参构造函数和是否调用父类的有参数的构造函数无必然联系 2.接口继承的时候,只能继承接口不能继承类,因为如果类 ...

  9. bug_ _fragment_“The specified child already has a parent. You must call removeView"的解决以及产生的原因

    这个异常的出现往往是因为非法使用了某些方法引起的. 从字面意思上是说这个特定的child已经有一个parent了,你必须在这个parent中首先调用removeView()方法,才能继续你的内容.这里 ...

随机推荐

  1. 【LSTM】Understanding-LSTMs

    http://colah.github.io/posts/2015-08-Understanding-LSTMs/

  2. FormData 对象的使用

    FormData 对象的使用 在本文章中 如何创建一个FormData对象 通过HTML表单创建FormData对象 使用FormData对象上传文件 通过AJAX提交表单和上传文件可以不使用Form ...

  3. redis 的set数据类型

    相关命令 1.SADD SADD key-name item1 [item 2…] 将一个或多个成员元素加入到集合中 2.SREM SMEMBERS  key-name item1 [item 2…] ...

  4. Base64编码——学习笔记

    Base64是一种编码方式. 非加密 chcp->936 编码流程: 位数不够后面补0,例中补了2个0. 末尾加=表示结束符. GB2312,有些敏感词不能显示. GBK,是GB2312升级版. ...

  5. JBOSS 数据源配置并使用JNDI调用

    -- 本文出自sleest (感谢yangjj ^_^) 场景分析: 某天系统的数据库维护方要求进行DG备库容灾演练,要把生产用RAC库模拟宕机并转移至DG备库上,由于是failover而不是swit ...

  6. Dubbo -- 系统学习 笔记 -- 成熟度

    Dubbo -- 系统学习 笔记 -- 目录 成熟度 功能成熟度 策略成熟度 啦啦啦

  7. 2. Oracle体系结构

    一. Oracle体系结构图 体系结构图如下: 体系结构图看似简单:其中很有玄机.它对Oracle来讲:相当于武功中的心法.配合体系结构来学Oracle:能起到事半功倍的效果.我们平时遇到Oracle ...

  8. Windows 2012 R2 安装Nessus

    1.nessus官网注册 注册地址:https://www.tenable.com/products/nessus-home Name字段随意,邮箱需要填写自己的,方便接受注册码 2.注册后,登录邮箱 ...

  9. c++对象的生命周期

    C++ 的new 运算子和C 的malloc 函数都是为了配置内存,但前者比之后者的优点是,new 不但配置对象所需的内存空间时,同时会引发构造式的执行. 所谓构造式(constructor),就是对 ...

  10. 启用PAE后虚拟地址到物理地址的转换

      34 注册:2013-10 帖子:2013 精华:34 --> [原创]启用PAE后虚拟地址到物理地址的转换 安于此生 2013-11-3 20:54 16073 由常规的两级页表转换得不到 ...