Android 包含片段的对话框
我试图制作一个包含片段的对话框, 我使用了DialogFragment,它第一次在对话框打开时工作正常, 但当我再次尝试打开对话框时,它崩溃了 代码如下:Android 包含片段的对话框,android,android-dialogfragment,Android,Android Dialogfragment,我试图制作一个包含片段的对话框, 我使用了DialogFragment,它第一次在对话框打开时工作正常, 但当我再次尝试打开对话框时,它崩溃了 代码如下: public class Map_dialog extends DialogFragment { private GoogleMap mMap; @Override public Dialog onCreateDialog(Bundle savedInstanceState) { LayoutInflater li = Lay
public class Map_dialog extends DialogFragment {
private GoogleMap mMap;
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
LayoutInflater li = LayoutInflater.from(getActivity());
View promptsView = li.inflate(R.layout.map, null);
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(getActivity());
mMap = ((MapFragment) getFragmentManager().findFragmentById(
R.id.map)).getMap();
mMap.setMyLocationEnabled(true); // set the current location
alertDialogBuilder.setView(promptsView);
alertDialogBuilder
.setPositiveButton("OK",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int id) {
}
});
return alertDialogBuilder.create();
} }
以下是XML代码:
`<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >`
<fragment
android:id="@+id/map"
android:name="com.google.android.gms.maps.MapFragment"
android:layout_width="wrap_content"
android:layout_height="match_parent" /></LinearLayout>
不管我是否使用地图,我试图制作一个不包含地图的简单片段
它仍然在第二次崩溃
我将感谢任何帮助 它崩溃->LogCat09-16 16:29:38.200:E/AndroidRuntime23321:FATAL异常:main 09-16 16:29:38.200:E/AndroidRuntime23321:android.view.InflateException:Binary XML文件行6:错误膨胀类片段09-16:29:38.200:E/AndroidRuntime23321:at-android.view.LayoutInflater.createViewFromTagLayoutInflater.java:710 09-1616:29:38.200:E/AndroidRuntime23321:at android.view.LayoutFlater.rInflateLayoutInflater.java:752 09-16:29:38.200:E/AndroidRuntime23321:at android.view.LayoutFlater.InflateLayoutFlater.java:495 09-16:29:38.200:E/AndroidRuntime23321:at android.view.LayoutFlater.InflateLayoutFlater