The specified child already has a parent. You must call removeView() on the child's parent first.经常会在我们removeView时出现,很是糟心:
因为有时候不确定view的parent对象。解决方案:
if(view.getParent()!=null){
((ViewGroup)view.getParent()).removeView(view);
}
这样view对象就能remove掉,并且不会报空指针~