-1

Hi I'm trying to implement Google Maps display in my app using Google Map Android API v2, and I am trying to follow the solution in here.

Codes seem to be okay except when I tried this part:

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);
    mMap = getMap();
    return root;
    }
}

The getMap() gives an error, as it says method getMap() is undefined for the type MapFragment. What does this mean?

4

1 回答 1

-1

getMap()方法是com.google.android.gms.maps.SupportMapFragment类的一部分。您SherlockMapFragment应该首先扩展它,因此只需使用getMap()shoudl 即可正常工作,但除非您使用 MapFragment 中的 ActionBar 而不是您的 FragmentActivity 进行一些实际的额外自定义,否则您可以SupportMapFragment首先扩展。

于 2013-02-16T01:44:15.563 回答