替换Fragment 报错 The specified child already has a parent. You must call removeView() on the child's pa
来源:互联网 发布:人为什么会孤独 知乎 编辑:程序博客网 时间:2024/05/23 18:30
在将一个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中,就会抛出这类错误信息。
相同问题的其他文章:
http://www.cnblogs.com/shenbin/archive/2012/03/15/2398209.html
http://www.cnblogs.com/over140/archive/2013/06/06/3121354.html
0 0
- 替换Fragment 报错 The specified child already has a parent. You must call removeView() on the child's pa
- viewpage:The specified child already has a parent. " + "You must call removeView() on the child's pa
- RecyclerView The specified child already has a parent. You must call removeView() on the child's pa
- . 报错 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.
- 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
- C++ 标准库之iomanip
- 好的JavaScript开发人员关键看哪里
- iOS学习笔记
- wps常用快捷键
- mongodb无法启动,由于目标计算机积极拒绝,无法连接
- 替换Fragment 报错 The specified child already has a parent. You must call removeView() on the child's pa
- 只用vs2008写qt程序
- 如何解决“error LNK1123: 转换到 COFF 期间失败”
- Java源码---java.lang.Math
- 安卓获取手机上的联系人
- 语音增强国外牛人
- spring mvc常用的注解:
- 说话人识别----技术挑战点
- Visual Studio 连接 SQL Server 的connectionStringz和