zoukankan      html  css  js  c++  java
  • 【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 call removeView() on the child's parent first.

    信息补充:

    使用FragmentActvitiy + Fragment

    错误原因:

        @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
            View v = inflater.inflate(R.layout.preference_fragment, container);

    解决办法: 

    View v = inflater.inflate(R.layout.preference_fragment, container, false);

    补充信息:

    导致此错误并不一定就是这个原因,大家也能搜到很多其他的原因,这里备注一下。 

    之前使用ActionBar里面的Fragment好像是可以的。 

  • 相关阅读:
    第17章 委托
    第16章 数组
    第15章 枚举类型和位标志
    第14章 字符、字符串和文本处理
    第13章 接口
    第12章 泛型
    第10章 属性
    第11章 事件
    内部类(转载)
    Collections.sort的三种用法
  • 原文地址:https://www.cnblogs.com/over140/p/3121354.html
Copyright © 2011-2022 走看看