在Android应用程序中,如何在TabHost下方(而不是内部)获取ListView?

在Android应用程序中,如何在TabHost下方(而不是内部)获取ListView?,android,listview,android-tabhost,Android,Listview,Android Tabhost,嘿,我有一个TabHost,它有两个选项卡,每个选项卡都有一个活动 第一个是具有普通文本视图的活动。 第二个选项卡是带有ListView的ListActivity 这一切都很好。 但是,我想在TabHost下面添加另一个listview。 所以基本上我会: 选项卡按钮 选项卡内容(活动:文本或列表) 列表视图 My main.xml: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http

嘿,我有一个TabHost,它有两个选项卡,每个选项卡都有一个活动

第一个是具有普通文本视图的活动。 第二个选项卡是带有ListView的ListActivity

这一切都很好。 但是,我想在TabHost下面添加另一个listview。 所以基本上我会: 选项卡按钮 选项卡内容(活动:文本或列表) 列表视图

My main.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <TabHost
        android:id="@android:id/tabhost"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
        <LinearLayout
            android:orientation="vertical"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:padding="5dp">
            <TabWidget
                android:id="@android:id/tabs"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content" />
            <FrameLayout
                android:id="@android:id/tabcontent"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:padding="5dp" />
        </LinearLayout>
    </TabHost>
    <ListView android:id="@+id/footerlist"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>
</LinearLayout>

但是,我真的不知道如何设置页脚列表的数据。 使用ListView的活动需要扩展ListActivity。。。 但是我的主活动扩展了TabActivity,因此我不确定如何填写列表数据,因为如果不扩展ListActivity,我就无法使用ListAdapter。
有人知道解决方案吗?

使用
列表视图的活动可以是简单的
活动
,而不仅仅是
列表活动
。因此,只需将其添加到
列表视图下的xml布局中即可。顺便说一句,
TabHost
可以包含在普通的
活动中,而不是
TabActivity
中。

已修复。 我使用了一个
RelativeLayout
而不是
ListLayout

我的最终XML(如果对任何人有用):



如何将实际数据从主活动获取到
列表视图中?
ListView ListView=(ListView)findViewById(R.id.your\u list\u view\u id)
listView.setAdapter(yourListAdapter)
//或者您想对您的
ListView
执行的任何操作:
ListView footerList=(ListView)findViewById(R.id.footerList)
footerList.setAdapter(应显示“not”的新ArrayAdapter应工作:)Mb您遗漏了某些内容,或者可能是特定于tabhost的。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <TabHost
        android:id="@android:id/tabhost"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_above="@+id/footerlist"
        android:layout_alignParentTop="true">
        <LinearLayout
            android:orientation="vertical"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent">
            <TabWidget
                android:id="@android:id/tabs"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content" />
            <FrameLayout
                android:id="@android:id/tabcontent"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:paddingTop="5dp"
                android:paddingLeft="5dp"
                android:paddingRight="5dp" />
        </LinearLayout>
    </TabHost>
    <ListView android:id="@+id/footerlist"
        android:layout_alignParentBottom="true"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"/>
</RelativeLayout>