首页 > 编程语言 > 详细

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

时间:2016-12-30 13:17:45      阅读:163      评论:0      收藏:0      [点我收藏+]

在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://stackoverflow.com/questions/13559353/how-to-solve-for-viewpager-the-specified-child-already-has-a-parent-you-must

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

原文:http://www.cnblogs.com/expiator/p/6236235.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!