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

来源:互联网 发布:钢结构荷载计算软件 编辑:程序博客网 时间:2024/06/06 02:01

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);

成功。暂时解决。。。以后有坑再更。

阅读全文
0 0
原创粉丝点击