I am inflatng a mapview every time i call this function. And am also removing the view each time . but still i get an error saying the child already has a parent ,call removeview() first.
Any idea of how to solve this .
void getGeoView(Context context) {
myRoot.removeAllViews();
LayoutInflater inflater = (LayoutInflater) this
.getSystemService(LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.geo_inflator, null);
((ViewGroup) view.findViewById(R.id.myMap)).removeAllViews();
if (mapView == null) {
mapView = new MapView(this, "0IEmqsWhwmo6Cu8hKdYn_VudUT8IpdKpXzMvQyw");
((ViewGroup) view.findViewById(R.id.myMap)).addView(mapView);
} else {
((ViewGroup) view.findViewById(R.id.myMap)).addView(mapView);
}
I’m not sure what you are doing but the simplest solution is to add this line:
to wherever the error occurs. I guess that happens here: