I\'ve been trying insert a MapView
into an ActionBar
Tab
, but I wasn\'t able to solve the problem even googling.
Here is the Main
Solution is to start mapview in the main activity which should extend FragmentMapActivity. Then your fragment can implement the mapview by getting it from the main activity.
Main activity:
mMapView = new MapView(YourActivity.this, MAPS_KEY);
mMapView.setClickable(true);
Exchanger.mMapView = mMapView;
Fragment:
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
mMapView = Exchanger.mMapView;
return mMapView;
}
@Override
public void onDestroy() {
if(mMapView != null) {
NoSaveStateFrameLayout parentView = (NoSaveStateFrameLayout) mMapView.getParent();
parentView.removeView(mMapView);
}
super.onDestroy();
}
Exchanger is a class with a static field with mapview in it.