Android fragments 为创建MapFragment的活动实现操作栏选项卡

Android fragments 为创建MapFragment的活动实现操作栏选项卡,android-fragments,android-tabs,android-maps-v2,Android Fragments,Android Tabs,Android Maps V2,这是一个类似的问题:但我没有从中得到一个明确的答案。我是Android新手,这是我开发的第一个应用程序 我目前有一个主要活动,为Google Maps v2创建一个MapFragment。并在操作栏下显示地图,如图所示 我的目标是为Eclipse中的MainActivity实现选项卡(不使用FragmentActivitys或支持库,因为我的应用程序是minSdkVersion=11),它当前为Google Maps v2创建了一个MapFragment MainActivity.java代码段

这是一个类似的问题:但我没有从中得到一个明确的答案。我是Android新手,这是我开发的第一个应用程序

我目前有一个主要活动,为Google Maps v2创建一个
MapFragment
。并在操作栏下显示地图,如图所示

我的目标是为Eclipse中的MainActivity实现选项卡(不使用
FragmentActivity
s或支持库,因为我的应用程序是
minSdkVersion=11
),它当前为Google Maps v2创建了一个
MapFragment

MainActivity.java代码段

public class MainActivityextends Activity 
implements LocationListener, LocationSource, OnMarkerClickListener, OnInfoWindowClickListener {
    private static GoogleMap googleMap;

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.map); 
        actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); //Change to Tab mode 
        ....
        googleMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();

map.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <include 
    android:id="@+id/map"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    layout="@layout/map_fragment" />
</LinearLayout>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
android:id="@+id/map"
android:name="com.google.android.gms.maps.MapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
map:cameraTargetLat="53.78513542767"
map:cameraTargetLng="-3.14948167651"
map:cameraZoom="14" />
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
map:cameraTargetLat="53.78513542767"
map:cameraTargetLng="-3.14948167651"
map:cameraZoom="14" />
我需要使用标签,因为目前只开发了一个页面/活动,我需要一种向用户和地图显示过滤器的方法。用户将切换到相邻选项卡以编辑过滤器,并能够切换回地图选项卡,然后在地图选项卡上拾取过滤器并更改地图上的标记


这么简单的问题是,有没有一种简单的方法可以让我为自己的应用程序实现选项卡?如果不清楚,请询问具体情况,但这对我来说非常高级

尝试使用SupportMapFragment而不是MapFragment:

map.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <include 
    android:id="@+id/map"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    layout="@layout/map_fragment" />
</LinearLayout>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
android:id="@+id/map"
android:name="com.google.android.gms.maps.MapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
map:cameraTargetLat="53.78513542767"
map:cameraTargetLng="-3.14948167651"
map:cameraZoom="14" />
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
map:cameraTargetLat="53.78513542767"
map:cameraTargetLng="-3.14948167651"
map:cameraZoom="14" />