今天在做LinearLayout添加MapView的时候使用:

 

 
    
  1. Java代码  
  2.       
  3. layoutView.removeAllViews();        
  4. layoutView.addView(baidumap);    

这段代码报如下异常:

 

 
    
  1. Java代码  
  2.       
  3. The specified child already has a parent. You must call removeView() on the child's parent first    

实践证明baidumap依旧还有parent,于是在打开该视图之前,再调用多一次layoutView.removeAllViews()方法解决,真是奇怪。