1

我正在尝试实施谷歌地图。但是我收到了 Inflating 错误。谁能提供一个示例代码来实现谷歌地图。

谢谢

这是我的代码

public class GMap extends FragmentActivity implements LocationListener{

    public static GoogleMap mMap;
    LocationManager locationManager;
    Criteria criteria;
    String provider;
    Location location;



      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_gmap);
          setUpMapIfNeeded();
      }
      @Override
      protected void onResume() {
          super.onResume();
          setUpMapIfNeeded();
      }
 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.map))
              .getMap();
            // Check if we were successful in obtaining the map.
        if (mMap != null) {
                setUpMapIfNeeded();
      }
  }
}
4

0 回答 0