如何将Google Maps V2显示到AlertDialog android中

如何将Google Maps V2显示到AlertDialog android中,android,google-maps,android-alertdialog,Android,Google Maps,Android Alertdialog,我创建了一个android应用程序,我想在AlertDialog中显示Google Maps V2 我的代码是: LayoutInflater layoutInflater = LayoutInflater.from(getApplicationContext()); View promptView = layoutInflater.inflate(R.layout.prompt_mapview, null); AlertDi

我创建了一个android应用程序,我想在AlertDialog中显示Google Maps V2

我的代码是:

 LayoutInflater layoutInflater = LayoutInflater.from(getApplicationContext());

                View promptView = layoutInflater.inflate(R.layout.prompt_mapview, null);

                AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(
                        BasicProfileSetup.this);
                alertDialogBuilder.setView(promptView);
                alertDialogBuilder.setCancelable(false);

                final AlertDialog alertD = alertDialogBuilder.create();


                Button close = (Button) promptView.findViewById(R.id.btnClose_promptMapView);

                // Some Code for initialize MAP

                close.setOnClickListener(new OnClickListener()
                {
                    @Override
                    public void onClick(View arg0)
                    {
                        alertD.cancel();
                    }
                });

                alertD.show();
prompt_mapview.xml

    <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:orientation="vertical" >

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:orientation="horizontal" >

            <Button
                android:id="@+id/btnClose_promptMapView"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="Close" />

        </LinearLayout>

        <fragment
            android:id="@+id/map_promptMapView"
            android:name="com.google.android.gms.maps.MapFragment"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />

    </LinearLayout>

</RelativeLayout>
任何帮助都将不胜感激


谢谢。

尝试创建一个类似于警报对话框的新活动,并将地图放在上面。

尝试创建一个类似于警报对话框的新活动,并将地图放在上面。

是否可以发布提示\u mapview代码?使用自定义对话框。请参阅此-@yuvaツ. 那代码对我有用。。谢谢!!!不客气,亲爱的……)投票支持这个答案。@yuvaツ 但在这方面,地图显示得很暗。为什么会发生这种情况?您可以发布提示\u mapview代码吗?使用自定义对话框。请参阅此-@yuvaツ. 那代码对我有用。。谢谢!!!不客气,亲爱的……)投票支持这个答案。@yuvaツ 但在这方面,地图显示得很暗。为什么会发生这种情况?它不能满足用户的需要。它不能满足用户的需要
android.view.InflateException: Binary XML file line #33: Error inflating class fragment