0

カスタムダイアログにマップv2を表示したいのですが、マップも表示されますが、カスタムダイアログを閉じてもう一度カスタムダイアログが呼び出されると、ここにエラーが表示され、そのクラスのコードを入力します

活動クラス

public class MainActivity extends  FragmentActivity {


     PopupWindow pw;
     GoogleMap map;
     final Context context = this;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

         DisplayMetrics displaymetrics = new DisplayMetrics();
            getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);

          final int  screenheight = displaymetrics.heightPixels;
          final int   screenwidth = displaymetrics.widthPixels;

        Button button= (Button)findViewById(R.id.button);
        button.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                // custom dialog
                final Dialog dialog = new Dialog(context);

                dialog.getWindow().setLayout((screenwidth*90)/100,(screenheight*90)/100);
                dialog.setContentView(R.layout.popupstellodetailpage);
                dialog.setTitle("Title...");

                map= ((SupportMapFragment) getSupportFragmentManager()
                       .findFragmentById(R.id.popupmapview)).getMap(); 


                Button dialogButton = (Button) dialog.findViewById(R.id.buttoncancel);
                // if button is clicked, close the custom dialog
                dialogButton.setOnClickListener(new OnClickListener() {
                    @Override
                    public void onClick(View v) {

                        dialog.dismiss();
                    }
                });

                dialog.show();


            }
        });

    }

main.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity" >

    <Button
        android:id="@+id/button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:layout_marginTop="100dp"
        android:text="Button" />

</RelativeLayout>

Popupsteldetail.xml

<

LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/popuplayout"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@android:color/black"
    android:orientation="vertical" >

        <Button
            android:id="@+id/buttoncancel"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Cancel"
            android:layout_gravity="right"
             />

          <fragment
                    android:id="@+id/popupmapview"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:layout_margin="10dp"
                    class="com.google.android.gms.maps.SupportMapFragment" />



</LinearLayout>

Logcat エラー

04-17 13:09:06.391: E/AndroidRuntime(11978): FATAL EXCEPTION: main
04-17 13:09:06.391: E/AndroidRuntime(11978): android.view.InflateException: Binary XML file line #16: Error inflating class fragment
04-17 13:09:06.391: E/AndroidRuntime(11978):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
04-17 13:09:06.391: E/AndroidRuntime(11978):    at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
04-17 13:09:06.391: E/AndroidRuntime(11978):    at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
04-17 13:09:06.391: E/AndroidRuntime(11978):    at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
04-17 13:09:06.391: E/AndroidRuntime(11978):    at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
04-17 13:09:06.391: E/AndroidRuntime(11978):    at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:306)
04-17 13:09:06.391: E/AndroidRuntime(11978):    at android.app.Dialog.setContentView(Dialog.java:467)
04-17 13:09:06.391: E/AndroidRuntime(11978):    at com.example.stiptis.MainActivity$1.onClick(MainActivity.java:58)
04-17 13:09:06.391: E/AndroidRuntime(11978):    at android.view.View.performClick(View.java:4222)
04-17 13:09:06.391: E/AndroidRuntime(11978):    at android.view.View$PerformClick.run(View.java:17273)
04-17 13:09:06.391: E/AndroidRuntime(11978):    at android.os.Handler.handleCallback(Handler.java:615)
04-17 13:09:06.391: E/AndroidRuntime(11978):    at android.os.Handler.dispatchMessage(Handler.java:92)
04-17 13:09:06.391: E/AndroidRuntime(11978):    at android.os.Looper.loop(Looper.java:137)
04-17 13:09:06.391: E/AndroidRuntime(11978):    at android.app.ActivityThread.main(ActivityThread.java:4895)
04-17 13:09:06.391: E/AndroidRuntime(11978):    at java.lang.reflect.Method.invokeNative(Native Method)
04-17 13:09:06.391: E/AndroidRuntime(11978):    at java.lang.reflect.Method.invoke(Method.java:511)
04-17 13:09:06.391: E/AndroidRuntime(11978):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:994)
04-17 13:09:06.391: E/AndroidRuntime(11978):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:761)
04-17 13:09:06.391: E/AndroidRuntime(11978):    at dalvik.system.NativeStart.main(Native Method)
04-17 13:09:06.391: E/AndroidRuntime(11978): Caused by: java.lang.IllegalArgumentException: Binary XML file line #16: Duplicate id 0x7f040008, tag null, or parent id 0x0 with another fragment for com.google.android.gms.maps.SupportMapFragment
04-17 13:09:06.391: E/AndroidRuntime(11978):    at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:285)
04-17 13:09:06.391: E/AndroidRuntime(11978):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:676)
04-17 13:09:06.391: E/AndroidRuntime(11978):    ... 18 more
4

1 に答える 1

0

あなたのxmlの1行目を見て、あなたのlogcatは言う

于 2013-04-17T07:45:03.780 に答える