Android Mapview仅在使用intent(tabhost)启动时显示
我在FragmentActivity中使用了一个mapview,只有在意图调用它时才会显示该地图。在tabhost选项卡中,它保持空白。GetHttpResponse提供数据Android Mapview仅在使用intent(tabhost)启动时显示,android,maps,android-tabhost,Android,Maps,Android Tabhost,我在FragmentActivity中使用了一个mapview,只有在意图调用它时才会显示该地图。在tabhost选项卡中,它保持空白。GetHttpResponse提供数据 protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.layout_dua); mMapView = (MapView)
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.layout_dua);
mMapView = (MapView) findViewById(R.id.map);
mMapView.onCreate(savedInstanceState);
mMapView.onResume();
progressBar = (ProgressBar) findViewById(R.id.progressBar);
new GetHttpResponse(MyMapFragment1.this).execute();
mMapView.getMapAsync(this);
}
布局
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.gms.maps.MapView
xmlns:map="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/map"
android:layout_marginTop="20dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
您是否覆盖了中所述的所有方法
onCreate(Bundle),onResume()
等等,我还没有,这些方法里面应该有什么?你只需要调用mMapView.onCreate(savedInstanceState)
在你的片段onCreate
里面,文档中写的所有方法都是这样的,都做了,结果都一样。