MapActivity in fragment

I have a FragmentActivity :

 public class parking extends FragmentActivity { } 

It has 3 tabs, the second and third - lists resolved.

 public class tab2 extends Fragment{ } 

But the first one is a map, so I cannot extend the fragment and MapActivity .

How can I solve it?

+4
android
source share
2 answers

MapFragment support is not supported, the Android development team works with Android 3.0. Here's more information about the problem http://code.google.com/p/android/issues/detail?id=15347&utm_source=buffer&buffer_share=acc72 But you can create a fragment that returns MapActivity. Here is a sample code. Thanks inazaruk: https://github.com/inazaruk/examples/tree/master/MapFragmentExample How it works:

  • MainFragmentActivity is an activity that extends FragmentActivity and contains two MapFragments.
  • MyMapActivity extends MapActivity and has a MapView.
  • Hosts LocalActivityManagerFragment LocalActivityManager.
  • MyMapFragment extends LocalActivityManagerFragment and uses TabHost to create an internal instance of MyMapActivity.

If you have any doubts, please let me know.

+5
source share

Google has released the Maps API version 2 . This finally allows the use of MapFragment and SupportMapFragment . This allows you to add Maps to ViewPagers and to activities that do not extend MapActivity.

+4
source share

All Articles