Is there a way on use a MapFragment
, or a SupportMapFragment
, extending a DialogFragment
to be showed as a popup window, the same way as used to display a DatePicker?
I want to build it to let the user to select a LatLng from the map. I don't want to put the MapFragment
direct into the form because it is wrapped by a ScrollView
. Thanks for possible solutions.

- 153
- 11
-
You can use AlertDialog with Custom UI. That will fix, I think so. – Guna Dec 12 '12 at 13:47
-
Your tip is being puted into practice. Thank you. – Enio Carvalho Dec 12 '12 at 15:02
1 Answers
If you want to put to embed a map fragment into a dialog fragment, you can use the feature of nested fragment as implemented in Android 4.2 (ver 17). Example straight from android 4.2 api page:
Fragment videoFragment = new VideoPlayerFragment();
FragmentTransaction transaction = getChildFragmentManager().beginTransaction();
transaction.add(R.id.video_fragment, videoFragment).commit();
You can also import in the v4.support library's fragment class if you want compatibility from version 1.6 upwards. One downside of using the support library is that you must also use the dialogfragment that is in the support library. This might have the cascading effect of requiring that when you dynamically use the dialogfragment, the fragment library must be from the support library. If you have use the post honeycomb modern android library, you will not be able to mix in the use of the support library.
All is fine if your app is already using the support library. But this might not be the case. If you fall within this category, then you want to use mapview instead of mapfragment. Just create a layout (e.g. framelayout) in xml and dynamically add a new instance of mapview into this layout in code.

- 341
- 2
- 6