【发布时间】:2016-09-21 05:39:26
【问题描述】:
我在为地图充气时遇到问题。起初如果我点击EditText,它会启动,如果我取消/确定AlertDialog.Builder,然后再次点击EditText,它会导致:
E/MapError: android.view.InflateException: Binary XML file line #10: Error inflating class fragment
逻辑是:我已经完成了地区和省。通过MapFragment 中的地区和省来设置所选地区和省的相机位置,这是我除了 MapError 之外唯一的问题。
我的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"/>
我真的需要你的帮助。谢谢。
【问题讨论】:
-
是
AdminCreateEventActivity扩展FragmentActivity还是simple Activity? -
@M D:你在想
SupportMapFragment的问题吗? -
它
extendsAppCompatActivity. -
@RoCk 尝试扩展
FragmentActivity或使用SupportMapFragment -
我会试试你建议的答案。我会通知它是否有效。 :)
标签: android android-alertdialog mapfragment