android-mapview - Android 以编程方式创建的 MapView v2 不显示

标签 android-mapview google-maps-android-api-2

我更新了 Android Google Maps v2 示例应用程序中的 RawMapViewDemoActivity.java 以编程方式创建 MapView,但未显示 map 。我只是得到一个空白屏幕。

我换了

    mMapView = (MapView) findViewById(R.id.map);


    GoogleMapOptions options = new GoogleMapOptions();
    options.camera(new CameraPosition(new LatLng(0, 0), 15, 0, 0));         
    mMapView = new MapView(this, options);
    mMapView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));        

我究竟做错了什么?

最佳答案

你有没有把所有的livecycle方法都转发给新的MapView ?

mMapView.onCreate(savedInstanceState);

看看API Reference

关于android-mapview - Android 以编程方式创建的 MapView v2 不显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13808316/

相关文章:

java - 如何添加随缩放和位置而改变大小/位置的覆盖

android - 复制 map 跟随 Android 中的当前位置功能

android - 如何控制 Android MapView 上的叠加顺序?

android - 我应该使用 MapView 还是 MapFragment

android - 如何禁用标记点击事件?

android - 获取 gps 坐标 : continuously vs. 单个请求

android - android maps v2 上的聚类标记

java - Android Studio 谷歌地图自定义 map ,只想显示自定义 map 但使用谷歌地图功能

android - 想在我的应用程序中创建谷歌地图导航 - 自定义方式

android - Google Maps Android API v2 检测 map 上的长按并添加标记不起作用