转载:http://www.cnblogs.com/over140/archive/2013/06/06/3121354.html
错误信息:
Caused by: java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
信息补充:
使用FragmentActvitiy + Fragment
错误原因:
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.preference_fragment, container);
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.preference_fragment, container);
解决办法:
View v = inflater.inflate(R.layout.preference_fragment, container, false);
本文介绍了一个关于FragmentActivity与Fragment结合使用时出现的错误:试图添加的子视图已有父视图,需先调用removeView()移除。文章详细解释了错误原因,并给出了解决方案,即将inflate方法的最后一个参数设置为false。
852

被折叠的 条评论
为什么被折叠?



