當前位置: 首頁>>代碼示例>>Java>>正文


Java MapFragment.newInstance方法代碼示例

本文整理匯總了Java中com.google.android.gms.maps.MapFragment.newInstance方法的典型用法代碼示例。如果您正苦於以下問題:Java MapFragment.newInstance方法的具體用法?Java MapFragment.newInstance怎麽用?Java MapFragment.newInstance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.android.gms.maps.MapFragment的用法示例。


在下文中一共展示了MapFragment.newInstance方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onCreateView

import com.google.android.gms.maps.MapFragment; //導入方法依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    if(rootView == null) {
        rootView = inflater.inflate(R.layout.fragment_map, container, false);

        mMapFragment = MapFragment.newInstance();
        FragmentTransaction transaction = getChildFragmentManager().beginTransaction();
        transaction.add(R.id.map_container, mMapFragment).commit();
        getChildFragmentManager().executePendingTransactions();


        initMap();
    }
    return rootView;
}
 
開發者ID:martarodriguezm,項目名稱:clean-mercadona,代碼行數:17,代碼來源:SupermarketsMapFragment.java

示例2: createMap

import com.google.android.gms.maps.MapFragment; //導入方法依賴的package包/類
private MapFragment createMap()
{
	GoogleMapOptions options = new GoogleMapOptions();

	options.useViewLifecycleInFragment( true );
	options.compassEnabled( false );
	options.zoomControlsEnabled( false );

	final boolean mapControlEnabled = geMapControlsEnabled();
	options.zoomGesturesEnabled( mapControlEnabled );
	options.scrollGesturesEnabled( mapControlEnabled );
	options.rotateGesturesEnabled( mapControlEnabled );
	options.tiltGesturesEnabled( mapControlEnabled );

	options.mapType( GoogleMap.MAP_TYPE_SATELLITE );

	CameraPosition camPos = new CameraPosition( getLocation(), 0.0f, 30f, 0.0f );
	options.camera( camPos );

	MapFragment mapFragment = MapFragment.newInstance( options );

	return mapFragment;
}
 
開發者ID:Wavesonics,項目名稱:TMinus,代碼行數:24,代碼來源:LocationDetailFragment.java

示例3: onCreateView

import com.google.android.gms.maps.MapFragment; //導入方法依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    getActivity().setTitle(getString(R.string.title_activity_maps));
    view = inflater.inflate(R.layout.fragment_map, container, false);

    FragmentManager fm = getFragmentManager();

    boolean refresh = true;
    if(savedInstanceState!=null)
        refresh=false;

    MapFragment fr = (MapFragment) fm.findFragmentById(R.id.map);
    if(fr==null||refresh) {
        fr = MapFragment.newInstance();
        fm.beginTransaction().replace(R.id.map, fr).commit();
        moveCamera = true;
    } else {
        moveCamera = false;
    }

    MobileAds.initialize(this.getActivity(), this.getResources().getString(R.string.unit_id));

    AdView mAdView = (AdView) view.findViewById(R.id.adView);
    AdRequest adRequest = new AdRequest.Builder().addTestDevice(AdRequest.DEVICE_ID_EMULATOR).build();
    mAdView.loadAd(adRequest);

    fr.getMapAsync(this);

    return view;
}
 
開發者ID:majornuts,項目名稱:treehugger,代碼行數:31,代碼來源:MyMapFragment.java

示例4: onStart

import com.google.android.gms.maps.MapFragment; //導入方法依賴的package包/類
@Override
public void onStart() {
    super.onStart();

    this._mapFragment = MapFragment.newInstance();
    getFragmentManager().beginTransaction()
            .replace(R.id.container, this._mapFragment)
            .commit();
    _mapFragment.getMapAsync(this); //get map asynchron
}
 
開發者ID:DerGary,項目名稱:FHWS-Lectures,代碼行數:11,代碼來源:EventDetailFragment.java

示例5: onCreate

import com.google.android.gms.maps.MapFragment; //導入方法依賴的package包/類
@Override
protected void onCreate( Bundle savedInstanceState )
{
	super.onCreate( savedInstanceState );
	setContentView( R.layout.activity_main );

	this.mapFragment = MapFragment.newInstance( );
	getFragmentManager( ).beginTransaction( )
		.add( R.id.container, this.mapFragment )
		.commit( );
}
 
開發者ID:DerGary,項目名稱:FHWS-MobileApplikationen,代碼行數:12,代碼來源:MainActivity.java

示例6: onActivityCreated

import com.google.android.gms.maps.MapFragment; //導入方法依賴的package包/類
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    // Chargement d'un sous-fragment contenant la map
    FragmentManager fm = getChildFragmentManager();
    mMapFragment = (MapFragment) fm.findFragmentById(R.id.map_container);
    if (mMapFragment == null) {
        // On créé une instance de MapFragment (il ne faut pas passer par le constructeur !)
        mMapFragment = MapFragment.newInstance();
        // Chargement effectif du sous-fragment
        fm.beginTransaction().replace(R.id.map_container, mMapFragment).commit();
    }
}
 
開發者ID:cafejeunesse,項目名稱:application-cafe-jeunesse-android,代碼行數:14,代碼來源:GoogleMapFragment.java

示例7: onResume

import com.google.android.gms.maps.MapFragment; //導入方法依賴的package包/類
@Override
public void onResume() {
    super.onResume();
    mapFragment = (MapFragment) getFragmentManager().findFragmentByTag(TAG);
    if (mapFragment == null) {
        mapFragment = MapFragment.newInstance();
        mapFragment.getMapAsync(this);
        FragmentTransaction tx = getFragmentManager().beginTransaction();
        tx.add(R.id.map, mapFragment, TAG);
        tx.commit();
    } else {
        // load all markers
        LoaderManager lm = getLoaderManager();

        // load the tile overlays
        lm.initLoader(TOKEN_LOADER_TILES, null, mTileLoader).forceLoad();

        if (mMap == null) {
            mapFragment.getMapAsync(this);
        } else {
            setupMap(true, mMap);
        }


    }
    if (this.dialog != null) {
        this.dialog.getDialog().show();
    }
}
 
開發者ID:secondsun,項目名稱:devnexus-android,代碼行數:30,代碼來源:VenueMapFragment.java

示例8: onCreate

import com.google.android.gms.maps.MapFragment; //導入方法依賴的package包/類
@Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);

      //mListView = (ListView) findViewById(R.id.list);
      //mListView.setOverScrollMode(ListView.OVER_SCROLL_NEVER);

      mSlidingUpPanelLayout = (SlidingUpPanelLayout) findViewById(R.id.slidingLayout);
      mSlidingUpPanelLayout.setEnableDragViewTouchEvents(true);

      rlOrnek = (RelativeLayout)findViewById(R.id.rlOrnek);

      int mapHeight = getResources().getDimensionPixelSize(R.dimen.map_height);
      mSlidingUpPanelLayout.setPanelHeight(mapHeight); // you can use different height here
      mSlidingUpPanelLayout.setScrollableView(rlOrnek, mapHeight);

      mSlidingUpPanelLayout.setPanelSlideListener(this);

      // transparent view at the top of ListView
      mTransparentView = findViewById(R.id.transparentView);

      // init header view for ListView
      mTransparentHeaderView = LayoutInflater.from(this).inflate(R.layout.transparent_header_view, null, false);
      mSpaceView = mTransparentHeaderView.findViewById(R.id.space);

/*      ArrayList<String> testData = new ArrayList<String>(100);
      for (int i = 0; i < 100; i++) {
          testData.add("Item " + i);
      }*/
      //mListView.addHeaderView(mTransparentHeaderView);
      /*mListView.setAdapter(new ArrayAdapter<String>(this, R.layout.simple_list_item, testData));
      mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
              mSlidingUpPanelLayout.collapsePane();
          }
      });
      collapseMap();*/

      mMapFragment = MapFragment.newInstance();
      FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
      fragmentTransaction.add(R.id.mapContainer, mMapFragment, "map");
      fragmentTransaction.commit();

      setUpMapIfNeeded();
  }
 
開發者ID:mustafaguven,項目名稱:AndroidSlidingUpPanelFourSquareLike,代碼行數:48,代碼來源:MainActivity.java

示例9: onCreate

import com.google.android.gms.maps.MapFragment; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);
  
  // Populate the navigation drawer data
  drawerItems = getResources().getStringArray(R.array.drawer_array);
  drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
  drawerList = (ListView) findViewById(R.id.left_drawer);
  
  // Add the shadow over the main frame
  drawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
  
  // Set up the drawer's list view
  drawerList.setAdapter(new DrawerArrayAdapter(this, drawerItems));
  drawerList.setOnItemClickListener(new DrawerItemClickListener());

  // Enable action bar icon to toggle navigation drawer
  getSupportActionBar().setDisplayHomeAsUpEnabled(true);
  getSupportActionBar().setHomeButtonEnabled(true);
  
  // Set up ActionBar toggler
  drawerToggle = new ActionBarDrawerToggle(this,
                                           drawerLayout,
                                           R.string.drawer_open,
                                           R.string.drawer_close);
  drawerLayout.setDrawerListener(drawerToggle);

  mGoogleApiClient = new GoogleApiClient.Builder(this)
      .addApi(LocationServices.API)
      .addConnectionCallbacks(this)
      .addOnConnectionFailedListener(this)
      .build();


    // Add the map to the content frame
  if (findViewById(R.id.content_frame) != null) {
    // Don't create the map if resuming from a saved state
    if (savedInstanceState != null) {
      return;
    }
    
    GoogleMapOptions options = new GoogleMapOptions();      
    MapFragment mapFragment = MapFragment.newInstance(
        options.zoomControlsEnabled(false));
    getFragmentManager().beginTransaction()
        .add(R.id.content_frame, mapFragment, "map").commit();
    map = mapFragment.getMap();
  }
}
 
開發者ID:eric-zeng,項目名稱:MapJournal,代碼行數:51,代碼來源:MainActivity.java


注:本文中的com.google.android.gms.maps.MapFragment.newInstance方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。