您的位置:首页 > 其它

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

2015-03-26 09:34 471 查看
学习android 的 fragment时遇到The specified child already has a parent. You must call removeView() on the child's parent first的错误,

提示已经有父容器,通过调试一直是fragmentTransaction.commit();的错误,后来知道是fragment中的问题

View view = inflater.inflate(R.layout.activity_content, container);

原来这里默认绑定了一个container的容器,所以调用commit时提示已经有了父容器,只需改成
View view = inflater.inflate(R.layout.activity_content, container, false);

默认不绑定就可以了
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐