You must call removeView() on the child's parent first错误!
2017-03-25 23:30
1321 查看
在切换Fragement的时候出现:错误信息
前面已经提到:
LayoutInflater的inflate() 三参方法的第三个参数指示在加载期间,展开的layout是否应当附着到ViewGroup (第二个参数)。传入true会在最后的layout中创建一个多余的view group。
Fragment简单入门
所以使用使用两个参数的时候会报上述错误。
需要最后一个参数为false.
java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
前面已经提到:
LayoutInflater的inflate() 三参方法的第三个参数指示在加载期间,展开的layout是否应当附着到ViewGroup (第二个参数)。传入true会在最后的layout中创建一个多余的view group。
Fragment简单入门
所以使用使用两个参数的时候会报上述错误。
需要最后一个参数为false.
public class FragmentA extends Fragment { /** * * @param inflater 加载fragment的xml布局文件的填充器。其inflate方法可将布局文件转化成View对象 * @param container 你的fragment layout将要插入的父ViewGroup(来自activity的layout)。 * @param savedInstanceState 是一个Bundle,如果fragment是被销毁后恢复的,它提供关于fragment的之前的实例的数据()。 * @return 返回一个View类型的对象 */ @Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) { return inflater.inflate(R.layout.fragment_a,container,false); //第一个参数,是要填充那个。第二个参数是要填充到哪里。可以直接写,传来的父ViewGroup //如果第三个参数不写false切换fragment的时候报错误。 /* 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.
- Android 开发 Tip 4 -- You must call removeView() on the child's parent first
- . 报错 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.;
- 解决继承RecyclerView.Adapter界面崩溃及部分布局不显现的问题【 You must call removeView() on the child's parent first.】
- Android PopupWindow You must call removeView() on the child's parent first.
- BUG: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问题