替换Fragment 报错 The specified child already has a parent. You must call removeView() on the child's pa
2015-07-04 20:28
573 查看
在将一个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.
原因:
出现此错误的根本问题是当前VIEW已经在别的View中,作为别的子View,现在又要将当前VIEW放在别的View中,就会抛出这类错误信息。
相同问题的其他文章:
http://www.cnblogs.com/shenbin/archive/2012/03/15/2398209.html
http://www.cnblogs.com/over140/archive/2013/06/06/3121354.html
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中,就会抛出这类错误信息。
相同问题的其他文章:
http://www.cnblogs.com/shenbin/archive/2012/03/15/2398209.html
http://www.cnblogs.com/over140/archive/2013/06/06/3121354.html
相关文章推荐
- iOS学习笔记
- 好的JavaScript开发人员关键看哪里
- mongodb无法启动,由于目标计算机积极拒绝,无法连接
- 文曲星
- C++ 标准库之iomanip
- 大小端模式
- 一个苦逼站长四年的网络创业故事
- node.js在前端这个行业中所占的比例
- python获取绑定的IP,并动态指定出口IP
- 帮您分析济南网站优化和推广的区别?
- 观察者模式
- Linux线程同步
- JavaScript Object Prototypes
- 堆排序C++
- POJ 2241 The Tower of Babylon
- 自学笔记-C语言复习2015年7月4日
- 中文繁简互换以及获取中文字符串首字母
- 视图模型和分页
- project.pbxproj,最熟悉的”陌生人”
- 根据网络路径批量下载文件保存到本地