自定义Dialog,第二次点击item报The specified child already has a parent. You must call removeView() on the chil

来源:互联网 发布:龙渊网络 编辑:程序博客网 时间:2024/06/15 18:09

原来的对话框中间的view是可以移除的,代码:


contentView为外来传入的,当第一次对对话框进行确认事件的时候没问题,但第二次的时候就会报错:

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

 原因分析:

       第一次显示已经 有了一个ViewGroup,但第二次再次进入的时候,ViewGroup为同一个,在AS里面这种是不允许的,在eclipse里面不会报错。改正后的代码:


0 0