替换Fragment 报错 The specified child already has a parent. You must call removeView()
2014-10-10 15:37
651 查看
原文 /article/6104758.html
在将一个fragment替换到一个frameLayout的时候报错:
code: transaction.replace(R.id.fragment_container, fragment2);
错误: java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
原因:
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
//View newsView = inflater.inflate(R.layout.fragment_news, container);
View newsView = inflater.inflate(R.layout.fragment_news, container, false );
return newsView;
}
出现此错误的根本问题是当前VIEW已经在别的View中,作为别的子View,现在又要将当前VIEW放在别的View中,就会抛出这类错误信息。
相同问题的其他文章:
/article/6077653.html
/article/4602863.html
在将一个fragment替换到一个frameLayout的时候报错:
code: transaction.replace(R.id.fragment_container, fragment2);
错误: java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
原因:
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
//View newsView = inflater.inflate(R.layout.fragment_news, container);
View newsView = inflater.inflate(R.layout.fragment_news, container, false );
return newsView;
}
出现此错误的根本问题是当前VIEW已经在别的View中,作为别的子View,现在又要将当前VIEW放在别的View中,就会抛出这类错误信息。
相同问题的其他文章:
/article/6077653.html
/article/4602863.html
相关文章推荐
- 替换Fragment 报错 The specified child already has a parent. You must call removeView() on the child's pa
- 替换Fragment 报错 The specified child already has a parent. You must call removeView() on the child's parent first.
- bug_ _fragment_“The specified child already has a parent. You must call removeView"的解决以及产生的原因
- Fragment使用时出现错误:he specified child already has a parent. You must call removeView() on the child's p
- 动态的使用Fragment,出现异常The specified child already has a parent. You must call removeView"
- 嵌套Fragment的使用及遇到The specified child already has a parent. You must call removeView()问题的解决
- Fragment+FragmentActivity出现The specified child already has a parent. You must call removeView() on the child's parent first.
- fragment The specified child already has a parent. You must call removeView()
- android viewp嵌套Fragment时遇到The specified child already has a parent. You must call removeView()问题的解决
- 嵌套Fragment的使用及遇到The specified child already has a parent. You must call removeView()问题的解决
- java.lang.IllegalStateException The specified child already has a parent. You must call removeView()
- 【Android异常】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 异常信息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...
- 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 paren
- Android使用自定义对话框报错:The specified child already has a parent. You must call removeView() on the...
- 关于向父view添加相同的view问题!The specified child already has a parent. You must call removeView() on the chil
- 【Android异常】The specified child already has a parent. You must call removeView() on the child's parent first.