4

を に埋め込む必要がありSupportMapFragmentますDialog。これは私が考えることができる最高のものです:

public class SupportMapFragmentDialog extends DialogFragment {

    private final SupportMapFragment fragment;

    public SupportMapFragmentDialog() {
        fragment = new SupportMapFragment();
        setTargetFragment(fragment, 1);
    }

    @Override
    public View onCreateView(final LayoutInflater inflater,
            final ViewGroup container, final Bundle savedInstanceState) {
        return fragment.onCreateView(inflater, container, savedInstanceState);
    }

    public SupportMapFragment getFragment() {
        return fragment;
    }

}

ただし、これを呼び出すと:

final SupportMapFragmentDialog dialog = new SupportMapFragmentDialog();
dialog.show(getSupportFragmentManager(), "Historico");

私はこれを得る:

ここに画像の説明を入力

ダイアログでマップを表示するにはどうすればよいですか?

このアプリには、驚異的に機能する別のアプリがSupportMapFragmentあるため、構成とは何の関係もありません。

4

2 に答える 2

12

これにより、ダイアログにマップフラグメントを表示できます

public class DialogMapFragment extends DialogFragment {

    private SupportMapFragment fragment;

    public DialogMapFragment() {
        fragment = new SupportMapFragment();
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.mapdialog, container, false);
        getDialog().setTitle("");
        FragmentTransaction transaction = getChildFragmentManager().beginTransaction();
        transaction.add(R.id.mapView, fragment).commit();

        return view;
    }



    public SupportMapFragment getFragment() {
        return fragment;
    }
}

R.layout.mapdialog:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:padding="0dp" >

    <FrameLayout
        android:id="@+id/mapView"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >
    </FrameLayout>

</RelativeLayout>
于 2013-11-01T11:37:24.447 に答える