This is from a simple app with a listView and a google maps fragment. the listview is populated with preset locations. following code works for the first time the user touches a list item (i.e. opens the location specified within the "Locale" object) this is from my main activity:
@Override
public void onLocale(Locale locale) {
FragmentManager fm = getSupportFragmentManager();
FragmentTransaction ft = fm.beginTransaction();
// find the map fragment
Fragment mapFrag = DetailFrag.newInstance(locale);
if (isSingleLayout() == true) {
ft.replace(R.id.fragment_container, mapFrag, "map");
ft.addToBackStack(null);
} else {
ft.replace(R.id.fragment_container_details, mapFrag,
"map");
}
ft.commit();
}
and this is the fragment's onCreateView method, which crashes:
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
try {
View v = inflater.inflate(R.layout.frag_details, container, false);
Bundle details = getArguments();
float x = details.getFloat("x");
float y = details.getFloat("y");
FragmentManager fm = getFragmentManager();
SupportMapFragment innerMapFrag = (SupportMapFragment) fm
.findFragmentById(R.id.map);
// get the map object out of the map
GoogleMap map = innerMapFrag.getMap();
// set the map style
map.setMapType(GoogleMap.MAP_TYPE_SATELLITE);
// set the map camera position:
LatLng location = new LatLng(x, y);
map.moveCamera(CameraUpdateFactory.newLatLngZoom(location, 15));
return v;
} catch (InflateException e) {
Log.e(LOG,e.toString());
return null;
}
}