相关疑难解决方法(0)

旋转时回收Android Maps V2 SupportMapFragment

我希望在旋转设备时提高SupportMapFragment的性能.似乎必须重新创建片段.我不确定这一点,但是当旋转设备时,必须重新加载地图图块.从性能角度来看,保留并重用整个mapfragment而不必重新实例化片段是有意义的.任何洞察这一点将不胜感激.

我在xml中声明了SupportMapFragment,并使用api docs中描述的SetupMapIfNeeded().

private void setUpMapIfNeeded() {
    // Do a null check to confirm that we have not already instantiated the
    // map.
    if (mMap == null) {
        // Try to obtain the map from the SupportMapFragment.
        mMap = ((SupportMapFragment) getSupportFragmentManager()
                .findFragmentById(R.id.map)).getMap();
        // Check if we were successful in obtaining the map.
        if (mMap != null) {
            setUpMap();
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

android google-maps-android-api-2

7
推荐指数
1
解决办法
5398
查看次数

标签 统计

android ×1

google-maps-android-api-2 ×1