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

后端 未结 13 2148
余生分开走
余生分开走 2020-11-29 07:50

I create this post, because i am new at this, and i need a little help. I am doing a little exercise about a application you that put your name, and it returns \"hello (the

13条回答
  •  隐瞒了意图╮
    2020-11-29 08:19

    In onCreate with activity or onCreateView with fragment

     if (view != null) {
        ViewGroup parent = (ViewGroup) view.getParent();
        if (parent != null) {
            parent.removeView(view);
        }
    }
    try {
        view = inflater.inflate(R.layout.fragment_main, container, false);
    } catch (InflateException e) {
    
    }
    

提交回复
热议问题