com.google.android.gms.maps.SupportMapFragment.newInstance()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(3.3k)|赞(0)|评价(0)|浏览(136)

本文整理了Java中com.google.android.gms.maps.SupportMapFragment.newInstance()方法的一些代码示例,展示了SupportMapFragment.newInstance()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。SupportMapFragment.newInstance()方法的具体详情如下:
包路径:com.google.android.gms.maps.SupportMapFragment
类名称:SupportMapFragment
方法名:newInstance

SupportMapFragment.newInstance介绍

暂无

代码示例

代码示例来源:origin: facebook/facebook-android-sdk

private void toggleMapAndList() {
  state = state == State.MAP ? State.LIST : State.MAP;
  if (state == State.LIST) {
    if (mapFragment != null) {
      FragmentTransaction ft = getChildFragmentManager().beginTransaction();
      ft.hide(mapFragment).commit();
    }
    recyclerView.setVisibility(View.VISIBLE);
    currentPlaceCardView.setVisibility(View.VISIBLE);
  }
  if (state == State.MAP) {
    if (mapFragment == null) {
      mapFragment = SupportMapFragment.newInstance();
      FragmentTransaction transaction = getChildFragmentManager().beginTransaction();
      transaction.replace(R.id.place_search_map_placeholder, mapFragment);
      transaction.commit();
      mapFragment.getMapAsync(this);
    } else {
      FragmentTransaction ft = getChildFragmentManager().beginTransaction();
      ft.show(mapFragment).commit();
    }
    recyclerView.setVisibility(View.INVISIBLE);
    currentPlaceCardView.setVisibility(View.INVISIBLE);
  }
  displayPlaces(placesToDisplay);
}

代码示例来源:origin: googlemaps/android-samples

@Override
  public Fragment getItem(int position) {
    switch (position) {
      case 0:
      case 1:
        return new TextFragment();
      case 2:
        return SupportMapFragment.newInstance();
      default:
        return null;
    }
  }
}

代码示例来源:origin: googlemaps/android-samples

@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  // It isn't possible to set a fragment's id programmatically so we set a tag instead and
  // search for it using that.
  SupportMapFragment mapFragment = (SupportMapFragment)
      getSupportFragmentManager().findFragmentByTag(MAP_FRAGMENT_TAG);
  // We only create a fragment if it doesn't already exist.
  if (mapFragment == null) {
    // To programmatically add the map, we first create a SupportMapFragment.
    mapFragment = SupportMapFragment.newInstance();
    // Then we add it using a FragmentTransaction.
    FragmentTransaction fragmentTransaction =
        getSupportFragmentManager().beginTransaction();
    fragmentTransaction.add(android.R.id.content, mapFragment, MAP_FRAGMENT_TAG);
    fragmentTransaction.commit();
  }
  mapFragment.getMapAsync(this);
}

代码示例来源:origin: google-developer-training/android-advanced

@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_maps);
  // Obtain the SupportMapFragment and get notified when the map is ready
  // to be used.
  SupportMapFragment mapFragment = SupportMapFragment.newInstance();
  getSupportFragmentManager().beginTransaction()
      .add(R.id.fragment_container, mapFragment).commit();
  mapFragment.getMapAsync(this);
}

代码示例来源:origin: nglauber/dominando_android2

private void init() {
    Log.d("NGVL", "init::BEGIN");
    SupportMapFragment fragment = (SupportMapFragment)
        getSupportFragmentManager().findFragmentByTag(TAG);
    if (fragment == null) {
      fragment = SupportMapFragment.newInstance();
      getSupportFragmentManager()
          .beginTransaction()
          .replace(R.id.map, fragment, TAG)
          .commit();
    }
    mGoogleApiClient.connect();
    Log.d("NGVL", "init::END");
  }
}

代码示例来源:origin: SkyTreasure/Airbnb-Android-Google-Map-View

mapFragment = SupportMapFragment.newInstance();
getSupportFragmentManager().beginTransaction().replace(R.id.map, mapFragment).commit();

相关文章