0

我想在 mapView 上显示一个 listView,如下图 Google 地图应用程序所示。

最初只有地图是可见的。当用户单击选项卡时,我希望此 listView 出现在 mapView 上。

在此处输入图像描述

但问题是使用下面的布局不显示地图(灰屏可见)。但是,listView显示。

布局 :

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/pickMatchesLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <TabHost
        android:id="@+id/tabHost"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical" >

            <TabWidget
                android:id="@android:id/tabs"
                android:layout_width="match_parent"
                android:layout_height="wrap_content" >
            </TabWidget>

            <FrameLayout
                android:id="@android:id/tabcontent"
                android:layout_width="match_parent"
                android:layout_height="match_parent" >

                <RelativeLayout
                    android:id="@+id/map_layout"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent" >

                    <fragment
                        android:id="@+id/map"
                        android:name="com.google.android.gms.maps.MapFragment"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent" />

                    <include layout="@layout/listView" >
                    </include>
                </RelativeLayout>
            </FrameLayout>
        </LinearLayout>
    </TabHost>

</RelativeLayout>

设置标签的方法:

// Set up tabs
private void setUpTabs() {

    // Get TabHost
    tabHost = (TabHost) findViewById(R.id.tabHost);
    tabHost.setup();

    // Create tabs
    TabSpec sourceOnlyState = tabHost.newTabSpec(SOURCE_ONLY_STATE);
    sourceOnlyState.setContent(R.id.map);
    sourceOnlyState.setIndicator("Source Only");

    TabSpec allState = tabHost.newTabSpec(ALL_STATE);
    allState.setContent(R.id.map);
    allState.setIndicator("All");

    TabSpec mapTypes = tabHost.newTabSpec(MAP_FEATURES);
    mapTypes.setContent(R.id.map_layout);
    mapTypes.setIndicator("Map Types");

    // Add tabs in TabHost
    tabHost.addTab(sourceOnlyState);
    tabHost.addTab(allState);
    tabHost.addTab(mapTypes);

    // Set tab change listener
    tabHost.setOnTabChangedListener(this);
}
4

1 回答 1

0

选项卡的 OnClick 启动新活动并在该活动中执行与列表视图相关的所有代码并为活动设置主题是

android:theme="@android:style/Theme.Holo.Dialog.NoActionBar"
于 2013-08-07T10:02:17.000 回答