在ViewPager中,用Fragment显示页面时,报错:
java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child‘s parent first.
意思是:一个视图只能有一个父视图,必须先移除其他的父视图。
解决方法:
在Fragment的onCreateView()方法中,将
View view=inflater.inflate(R.layout.fragment_language, container);
改为:
View view=inflater.inflate(R.layout.fragment_language, container,false);
或者
View view=inflater.inflate(R.layout.fragment_language, null);
详情见StackOverflow:
原文:http://www.cnblogs.com/expiator/p/6236235.html