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

来源:互联网 发布:阿里云404页面设置 编辑:程序博客网 时间:2024/06/05 17:51
java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.

这种问题普遍出现在动态添加View时

也就是非法状态异常,它说这个特定的child已经有一个parent了,你必须在这个parent中首先调用removeView()方法,才能继续你的内容。这里很明显这个child是一个View,一个子(child)View必须依赖于父(parent)View,如果你要使用这个child,则必须通过parent,而你如果就是硬想使用这个child,那么就得让这个child与parent脱离父子关系(即removeView())……
0 0
原创粉丝点击