Skip to content Skip to sidebar Skip to footer

Error Using Maps In Fragment

i am having this error when i try to open my fragment 'activityMapa', apparently can't inflate my xml file: 11-15 21:58:39.769: E/AndroidRuntime(2432): FATAL EXCEPTION: main 11-15

Solution 1:

Create a class that derives from SupportMapFragment, and you won't need to inflate a layout.

publicclassMyMapFragmentextendsSupportMapFragment {

    privateGoogleMap map;

    @OverridepublicViewonCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        returnsuper.onCreateView(inflater, container, savedInstanceState);
    }

    @OverridepublicvoidonResume() {
        super.onResume();
        map = getMap();
    }

Then, when you need to use this in your activity's layout, you'd reference your class within the activity's layout xml

<fragment xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/map"
    android:layout_width="match_parent"
    android:layout_height="match_parent"class="com.example.despegarteproject.MyMapFragment" />

Post a Comment for "Error Using Maps In Fragment"