2016-09-21 59 views
0

我在充气地图时遇到问题。起初,如果我点击EditText它会推出,如果我取消/ ok了AlertDialog.Builder,然后再次单击EditText就会造成:MapFragment充气通过EditText激活

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

的逻辑是:我与地区进行,省。通过MapFragment中的区域和省来设置所选区域的相机位置&省,这是除MapError之外唯一的问题。

sample

我对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(); 
} 

我不能getView从该行代码。为了控制。我想@Override -setMapClickListener

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

我的充气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"/> 

我真的需要你的帮助。谢谢。

+1

是'AdminCreateEventActivity'延伸'FragmentActivity'或'简单Activity'? –

+0

@M D:你正在考虑一个'SupportMapFragment'问题? – gus27

+0

它'扩展'AppCompatActivity。 – RoCk

回答

0

我建议使用MapView用于片内的地图:

<?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> 
+0

我不这么认为,你可以使用任何'MapFragment'或'SupportMapFragment '内部'片段' –

+0

如果我更改了我的'MapFragment',我现在可以在我的视图中使用'getView'? – RoCk

+0

我的地图不见了:(我会为我的错误发布一个屏幕截图 – RoCk