0

Im having a problem in inflating the map. At first if I click the EditText It will launch, If I cancel / ok the AlertDialog.Builder , and click again the EditText it will cause:

E/MapError: android.view.InflateException: Binary XML file line #10: Error inflating class fragment

The logic is: I'm done with the Region and Province. Passing the Region and Province in the MapFragment to set Camera Position of the selected Region & Province, this is my only problem aside from the MapError.

sample :

My code for Map:

//START MAP FRAGMENT DIALOG
public void alertOrgMapSetMarker(){

    LayoutInflater layoutInflater = getLayoutInflater();
    View getView = layoutInflater.inflate(R.layout.map_inflate_org,null);
                   mapFragment = (MapFragment) getFragmentManager().findFragmentById(R.id.map_fragment_org);

    AlertDialog.Builder alertMap = new AlertDialog.Builder(AdminCreateEventActivity.this,R.style.AlertDialogCustom);
    alertMap.setTitle("Mark Location")
            .setView(getView)
            .setCancelable(false)
            .setPositiveButton("Set", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {

                }
            })
            .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {

                }
            });

    AlertDialog mapDialog = alertMap.create();
    mapDialog.show();
}

I cannot getView from this line of code. In order to have control. I want to @Override -setMapClickListener

mapFragment = (MapFragment) getFragmentManager().findFragmentById(R.id.map_fragment_org);

My inflated XML: map_inflate.xml

<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">

<fragment
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:name="com.google.android.gms.maps.MapFragment"
    android:id="@+id/map_fragment_org"
    map:cameraBearing="112.5"
    map:cameraTargetLat="10.3157"
    map:cameraTargetLng="123.8854"
    map:cameraTilt="45"
    map:cameraZoom="30"
    map:mapType="normal"
    map:uiCompass="true"
    map:uiRotateGestures="true"
    map:uiScrollGestures="true"
    map:uiTiltGestures="true"
    map:uiZoomControls="true"
    map:uiZoomGestures="true"
    tools:ignore="MissingPrefix"/>

I really need your help. Thank you.

Community
  • 1
  • 1
RoCkDevstack
  • 3,517
  • 7
  • 34
  • 56

1 Answers1

0

I'd suggest using a MapView for a Map inside a Fragment:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">

    <com.google.android.gms.maps.MapView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/map_fragment_org" />

</FrameLayout>
Graham
  • 7,431
  • 18
  • 59
  • 84
gus27
  • 2,616
  • 1
  • 21
  • 25