Skip to content Skip to sidebar Skip to footer

Binary Xml File Line #9: Error Inflating Class Fragment With Google Map Fragment

The map shows up perfectly when I first select the tab fragment, however if I navigate to other tab and reselect the map fragment tab it will throws me this error - 'Binary XML fil

Solution 1:

You canont remove/replace fragments that you used directly in your XML files (treat your layout structure from XML as read-only). If you want to be able to add/remove map or other fragments, you must remove it from XML and add from code (i.e. on onCreateView())

Solution 2:

The error probably says that it can't inflate because an entity already exists? If you want to do it this way you need to remove the reference to the map when u leave the tab in order for it to be able to be added again.

For example call a method:

public void cleanUp(){
    getFragmentManager().beginTransaction().remove(map).commit();
}

The way I suggest you do it is that you extend mapfragment instead of fragment, then you no longer need a layout file and no extra "tricks" are needed

Post a Comment for "Binary Xml File Line #9: Error Inflating Class Fragment With Google Map Fragment"