【问题标题】:ListView not display inside RelativeLayout from Tabhost in Android?ListView 不显示在 Android 中 Tabhost 的 RelativeLayout 内?
【发布时间】:2012-07-20 13:13:01
【问题描述】:

目前我在简单的 Android 应用程序中工作,使用 Tabhost 创建三个选项卡,第一个选项卡使用 RelativeLayout 创建 ListView,但 ListView 不可见,所以我尝试为 ListView 设置背景颜色(白色),如图所示只有白色的 ListView 没有显示,但结果相同,所以请帮助我,如何在 Android 的 Tabbar 中设置列​​表视图。

提前致谢

我试过了

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

  <RelativeLayout
    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_alignParentBottom = "true"
      android:layout_height="wrap_content"
     />

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




    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/tab1"

    android:layout_width="fill_parent"
    android:layout_height="200dip" >

    <ListView
        android:id="@+id/edittext01"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:background="#ffff"
        android:paddingTop="10px" />

</RelativeLayout>

【问题讨论】:

    标签: android android-listview android-tabhost android-relativelayout


    【解决方案1】:

    您实际上需要根据上面的选项卡指定 ListView 位置,然后使用 RelativeLayout 属性android:layout_above="id_of_FrameLayout_containing_ListView " 来显示您想要的列表。

    对于 ListView 中的内容,检查您添加的项目是否正确添加,以及是否使用 AdapterClass 来绘制每个列表项目..

    希望这个解释对你有用...

    【讨论】:

    猜你喜欢
    • 2010-12-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多