I\'m using Google Maps API V2 in an activity wih drop down navigation where the map is on the second position.
I\'m adding the map pragmatically like:
I'm not sure I'm completely understanding your issue, but I have a similar setup where I'm using a navigation drop down menu. Here's what works for me:
1.) Load the fragment from an xml file and call setupMapIfNeeded()
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.basicMap);
setUpMapIfNeeded();
Here is the xml file for reference:
2.) Then setup the map (for details of isGoogleMapsInstalled(), see this question)
private void setUpMapIfNeeded()
{
// Do a null check to confirm that we have not already instantiated the map.
if (mMap == null)
{
// Try to obtain the map from the SupportMapFragment.
mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.basicMap)).getMap();
// Check if we were successful in obtaining the map.
if(isGoogleMapsInstalled())
{
if (mMap != null)
{
mMap.setOnCameraChangeListener(getCameraChangeListener());
mMap.setInfoWindowAdapter(new MyCustomInfoWindowAdapter(this));
}
}
else
{
MapConstants.showDialogWithTextAndButton(this, R.string.installGoogleMaps, R.string.install, false, getGoogleMapsListener());
}
}
}
3.) Make sure you also call setUpMapIfNeeded() from onResume():
public void onResume()
{
super.onResume();
setUpMapIfNeeded();
}