【发布时间】:2009-11-18 13:39:37
【问题描述】:
Android 空列表布局
无论我做什么,我都无法显示空标签。在我的标签中,我有:
<LinearLayout
android:id="@+id/thisParticularTab"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView android:id="@+id/LastUpdated"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="List last updated: N/A" />
<ListView
android:id="@+id/mySpecialListView"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
<Button id="@android:id/empty"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="Click to fill the list" /></LinearLayout>
但是,尽管我的 ListView 为空(未显示任何项目,并且正在读取的数据库表为空),但未显示该按钮。有什么想法吗?
另外,当它出现时,我可以引用 R.id.empty 吗?这真的意味着我每个活动只能有 1 个 ListView/empty 吗?我的理解是“id”用于定义 UI 定义;我怎样才能给它一个名字,并将它分配为 XML 中的空视图? (我不想使用 setEmptyView())
【问题讨论】:
-
您需要使用 ListActivity 的实例才能使其工作 - @android:id/empty。否则,您需要创建一个具有常规 id 的自定义空视图 - @+id/empty。
标签: android user-interface listview