Android MapView Tab示例

我需要在选项卡上有一个mapview.
attached example显示了使用意图时如何执行此操作.
现在,我想更改mapview的缩放级别.
尽管我正在使用意图(或者完全存在),但我该怎么做?
不同的解决方案)?

活动代码

public class TabMapsExample extends tabactivity {    
    TabHost mTabHost;        
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);  
        Context ctx = this.getApplicationContext();         
        //tab 1
        mTabHost = getTabHost();
        TabSpec tabSpec1 = mTabHost.newTabSpec("tab_test1");
        tabSpec1.setIndicator("Map1");
        Intent i1 = new Intent(ctx,MapTabView.class);
        tabSpec1.setContent(i1);
        mTabHost.addTab(tabSpec1);          
        //tab2
        mTabHost = getTabHost();
        TabSpec tabSpec2 = mTabHost.newTabSpec("tab_test1");
        tabSpec2.setIndicator("Map2");
        Intent i2 = new Intent(ctx,MapTabView.class);
        tabSpec2.setContent(i2);
        mTabHost.addTab(tabSpec2);          
        //tab 3
        mTabHost = getTabHost();
        TabSpec tabSpec3 = mTabHost.newTabSpec("tab_test1");
        tabSpec3.setIndicator("Map");
        Intent i3 = new Intent(ctx,MapTabView.class);
        tabSpec3.setContent(i3);
        mTabHost.addTab(tabSpec3);    
    }
}

布局代码

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/maptablayout" android:orientation="vertical"
    android:layout_width="fill_parent" android:layout_height="fill_parent">
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_height="fill_parent" android:layout_width="fill_parent"
        android:background="#000000" android:orientation="vertical">
        <TextView xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="fill_parent" android:layout_height="50px"
            android:id="@+id/textview" />
        <com.google.android.maps.MapView
            android:id="@+id/mapview" android:layout_width="fill_parent"
            android:layout_height="fill_parent" android:clickable="true"
            android:apiKey="" />
    </LinearLayout>
</RelativeLayout>

谢谢

最佳答案
尝试使用MapController

    MapView mapView = (MapView) findViewById(R.id.mapview);
    mapView.setBuiltInZoomControls(true);
    MapController mapController = mapView.getController();
    mapController.setZoom(10);

另请参见Using Google Maps in Android

更新
您创建了几个具有相同布局的实例,并且存在通过id获取所需的MapView实例的问题.您可以为每个标签使用单独的布局吗?或动态创建它们?

相关文章

Android性能优化——之控件的优化 前面讲了图像的优化,接下...
前言 上一篇已经讲了如何实现textView中粗字体效果,里面主要...
最近项目重构,涉及到了数据库和文件下载,发现GreenDao这个...
WebView加载页面的两种方式 一、加载网络页面 加载网络页面,...
给APP全局设置字体主要分为两个方面来介绍 一、给原生界面设...
前言 最近UI大牛出了一版新的效果图,按照IOS的效果做的,页...