getSupportFragmentManager() method is undefined for type MapFragment

android, android-maps-v2, supportmapfragment

Solution

If you are using this SherlockMapFragment, try:

getSherlockActivity().getSupportFragmentManager();

Problem

I'm trying to implement Google Map display and below are my codes: ``` package com.fragments; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import com.google.android.gms.maps.GoogleMap; import com.google.android.gms.maps.SupportMapFragment; public class MapFragment extends SherlockMapFragment { private GoogleMap mMap; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View root = super.onCreateView(inflater, container, savedInstanceState); SupportMapFragment mapFrag= (SupportMapFragment)getSupportFragmentManager().findFragmentById(R.id.fragment_map); mMap = mapFrag.getMap(); return root; } } ``` Im getting an error that getSupportFragmentManager() is undefined for type MapFragment. However I'm a little confused as I have imported com.google.android.gms.maps.SupportMapFragment. shouldn't this method come from there then? Am I missing out some steps in getting this method to work?

Original source

Related problems