您的位置:首页 > 编程语言 > Java开发

java.lang.IllegalStateException: The specified child already has a parent. You must call removeView(

2017-11-24 16:52 627 查看

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

这个异常是在Fragment内嵌套TabLayout+ViewPager+Fragment的时候出现的。Tab数量:4个。前三个[Tab]可以随意滑动,可是滑动到第四个再滑到前三个任意一个的时候就出现了异常:

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


也是搜了很多网页查找解决办法,说是子View只能有一个父View。。。花了很多时间也没好。。。

最后我是猜测——前三个没事,就最后一个有问题,就把ViewPager设置缓存个

数`

setOffscreenPageLimit(3);


成功。暂时解决。。。以后有坑再更。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐