
我正在尝试使用Google Map V2.当我使用地图片段..一切正常.
但是,如果我使用mapvIEw,则会显示空白活动.
可能有什么不对?
XML:
<?xml version="1.0" enCoding="utf-8"?><linearLayout xmlns:androID="http://schemas.androID.com/apk/res/androID" androID:ID="@+ID/mapParent" androID:layout_wIDth="fill_parent" androID:layout_height="fill_parent" androID:orIEntation="vertical" > <com.Google.androID.gms.maps.MapVIEw androID:ID="@+ID/map" androID:layout_wIDth="match_parent" androID:layout_height="match_parent"/> </linearLayout>主要活动:
@OverrIDeprotected voID onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentVIEw(R.layout.activity_main);}解决方法:
您需要自己初始化地图:
@OverrIDeprotected voID onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentVIEw(R.layout.activity_main); // Gets the MapVIEw from the XML layout and creates it MapVIEw mapVIEw = (MapVIEw) findVIEwByID(R.ID.map); mapVIEw.onCreate(savedInstanceState); // Gets to GoogleMap from the MapVIEw and does initialization stuff GoogleMap map = mapVIEw.getMap(); // Needs to call MapsInitializer before doing any CameraUpdateFactory calls MapsInitializer.initialize(this); mapVIEw.onResume();} 总结 以上是内存溢出为你收集整理的android – Mapview显示空白但片段没问题全部内容,希望文章能够帮你解决android – Mapview显示空白但片段没问题所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)