大佬教程收集整理的这篇文章主要介绍了android – mapFragment.getMap()返回null,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
private GoogleMap map; private SupportMapFragment mapFragment; @Override public void onCreate( Bundle savedInstanceState ) { //... super.onCreate( savedInstanceState ); setContentView( R.layout.screen_mission2 ); GoogleMapOptions mapOptions = new GoogleMapOptions(); mapOptions.mapType(GoogleMap.MAP_TYPE_NORMAL) .compassEnabled@R_489_6334@ .rotateGesturesEnabled(false) .tiltGesturesEnabled(false); android.support.v4.app.FragmentManager myFragmentManager = getSupportFragmentManager(); android.support.v4.app.FragmentManager.enableDebugLogging@R_489_6334@; mapFragment = SupportMapFragment.newInstance(mapOptions); Fragmenttransaction fragmenttransaction = myFragmentManager.begintransaction(); fragmenttransaction.add(R.id.mapFragment,mapFragment); fragmenttransaction.commit(); myFragmentManager.executePendingtransactions(); if(mapFragment == null) Base.log("mapFragment==null"); if(map==null){ map = mapFragment.getMap(); Base.log("map should have been initialized"); if(map==null) Base.log("map still null"); } }@H_874_2@和布局文件:
<fragment android:id="@+id/mapFragment" android:name="com.google.android.gms.maps.SupportMapFragment" android:layout_width="match_parent" android:layout_height="match_parent" />@H_874_2@它返回以下日志
V/FragmentManager(24224): add: SupportMapFragment{4078c4b8 id=0x7f06003D} V/FragmentManager(24224): Allocated fragment index SupportMapFragment{4078c4b8 #1 id=0x7f06003D} V/FragmentManager(24224): moveto CREATED: SupportMapFragment{4078c4b8 #1 id=0x7f06003D} D/EMR (24224): map should have been initialized D/EMR (24224): map still null
以上是大佬教程为你收集整理的android – mapFragment.getMap()返回null全部内容,希望文章能够帮你解决android – mapFragment.getMap()返回null所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。