当前位置: 首页>>代码示例>>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;未经允许,请勿转载。