作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
嘿,我有一个带有两个选项卡的 TabHost,每个选项卡都有一个 Activity 。
第一个是具有普通 textView 的 Activity。第二个选项卡是带有 ListView 的 ListActivity。
一切正常。但是,我想在 TabHost 下方添加另一个 ListView 。所以基本上我会:选项卡按钮选项卡内容( Activity :文本或列表) ListView
我的 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 的 Activity 需要扩展 ListActivity...但是我的主要 Activity 扩展了 TabActivity,所以我不确定如何填写列表数据,因为如果不扩展 ListActivity 就无法使用 ListAdapter。有人知道解决方案吗?
最佳答案
已修复。我使用了 RelativeLayout
而不是 ListLayout
我的最终 XML(如果对任何人有用的话):
<?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>
关于android - 如何在 Android 应用程序中的 TabHost 下方(不在其中)获取 ListView?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5376930/
我是一名优秀的程序员,十分优秀!