You must call removeView() on the child'
来源:互联网 发布:icmp有没有端口 编辑:程序博客网 时间:2024/06/06 02:51
报错截取:
java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first. at android.view.ViewGroup.addViewInner(ViewGroup.java:4070) at android.view.ViewGroup.addView(ViewGroup.java:3920) at android.view.ViewGroup.addView(ViewGroup.java:3861) at android.view.ViewGroup.addView(ViewGroup.java:3834)
关于这个报错问题 曾出现过两次
1、ViewPager 的 轮播时出现2、点击RadioButton时 切换Fragment 出现报错
第一个问题 解决
这是在ViewPager的适配器中
@Override public Object instantiateItem(ViewGroup container, int position) { position%=mImageViewsFoot.size(); if(position<0){ position=mImageViewsFoot.size()+position; } ImageView img=mImageViewsFoot.get(position); ViewParent viewParent=img.getParent(); if(viewParent!=null){ ViewGroup viewGroup= (ViewGroup) viewParent; viewGroup.removeView(img); } container.addView(img); return img; } @Override public void destroyItem(ViewGroup container, int position, Object object) { }
第二个问题 解决
因为 没有 返回attachToRoot == false
/** * @param resource ID for an XML layout resource to load 填充界面ID * @param root 如果有父容器 则写 ; 没有 则写null * @param attachToRoot 他会自动把layout加到View hierarchy中 * @return 返回界面 */ public View inflate(@LayoutRes int resource, @Nullable ViewGroup root, boolean attachToRoot)
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.sub_recommand_fragment,container,false);
0 0
- You must call removeView() on the child'
- You must call removeView() on the child's parent first
- You must call removeView() on the child's parent first
- The specified child already has a parent. You must call removeView() on the chil
- The specified child already has a parent. You must call removeView() on the
- You must call removeView() on the child's parent first错误的解决方法
- Android PopupWindow You must call removeView() on the child's parent first.
- Android关于You must call removeView() on the child's parent first的解决
- You must call removeView() on the child's parent first错误!
- Android 开发 Tip 4 -- You must call removeView() on the child's parent first
- The specified child already has a parent. You must call removeView() on the child's parent first.
- 二、The specified child already has a parent. You must call removeView() on the child's parent first.
- The specified child already has a parent. You must call removeView() on the child's parent first
- The specified child already has a parent. You must call removeView() on the child's parent first
- 【Android异常】The specified child already has a parent. You must call removeView() on the child's paren
- The specified child already has a parent. You must call removeView() on the child's parent first.
- The specified child already has a parent. You must call removeView() on the child's parent first.
- The specified child already has a parent. You must call removeView() on the child's parent first
- 小试牛刀-如何用数据洞察一场直播
- Java Arrays.asList 实例
- listview有数据却显示不出来
- bzoj 1018: [SHOI2008]堵塞的交通traffic (线段树维护连通性)
- java二維數組練習
- You must call removeView() on the child'
- map用法
- omnet build速度很慢的可能解决方案
- 蓝桥杯 两道回文数 BASIC-8 BASIC-9
- 运营的一些简单方法
- ROS使用笔记本自带USB摄像头运行pi_face_tracker,进行人脸识别
- BZOJ 2440: [中山市选2011]完全平方数
- FEM简介
- 《暗时间》(刘未鹏)读书摘抄