The specified child already has a parent解决办法

The specified child already has a parent异常信息:Java codeThe specified child already has a parent.

The specified child already has a parent
异常信息:

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

出现这个异常的原因是:动态修改View是出现的错误

我做的Activity中有listView,长按之后弹出对话框"编辑",能对listView里面的内容进行编辑,

这么做第一次编辑的时候是没有异常的,为什么异常是在第二次长按的时候出现?

[解决办法]
可能是第一次编辑的时候给某个子view设置了parent,第二次长按的时候如果执行同样的代码,又设置了一个parent,系统发现子view已经有了父view, 就报错了,你检查一下代码呢