我試圖創建non-Activity
類顯示my current location, get latitude/longitude, show markers
....上Google Maps V2
但始終其報告的錯誤:谷歌地圖V2-無法解析法getSupportFragmentManager()在非活性類
無法解析方法getSupportFragmentManager ()
我想:
我的代碼部分
public final class AddDataGMapsV2 {
private static Context context;
public AddDataGMapsV2(Context context) {
this.context = context;
}
public void showMap(SupportMapFragment map, GoogleMap googleMap) {
//show map
//Line error below
map = (SupportMapFragment) context.getSupportFragmentManager().findFragmentById(R.id.map);
// Getting GoogleMap object from the fragment
googleMap = map.getMap();
// Enabling MyLocation Layer of Google Map
googleMap.setMyLocationEnabled(true);
}
//.......................
有什麼建議嗎?
它解決了只刪除該行,由於答案,但它解決了。 – Aspicas