[英]Android how to add a Listview to a Fragment instead of ListActivity
[英]Android ListActivity - how to add a view below the ListView?
我正在嘗試在 ListActivity 的 ListView 下方放置一個 ProgressBar 視圖。 我希望它始終位於 listView 的最后一行下方。
只要列表(在運行時由適配器填充)不超過屏幕,就會出現放置在 LinearLayout 中的 ProgressBar。 一旦列表大於屏幕,ProgressBar 就不再可見。
布局 xml 如下所示:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/db1_root"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<!-- Title bar -->
<LinearLayout
style="@style/TitleBar" >
<TextView
style="@style/TitleBarText"
android:text="Some title text" />
<ImageButton
style="@style/TitleBarAction"
android:contentDescription="@string/description_search"
android:src="@drawable/title_search" />
</LinearLayout>
<!-- Content -->
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="fill_parent" >
<ListView
android:divider="@drawable/category_item_divider"
android:dividerHeight="@dimen/list_divider_height"
android:layout_height="wrap_content"
android:id="@+id/android:list"
android:layout_width="fill_parent"
android:layout_weight="1" />
<TextView
android:id="@+id/android:empty"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="@string/category_no_items" />
</LinearLayout>
<!-- Progress bar -->
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content" >
<ProgressBar
android:id="@+id/productlist_progressbar"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
這對於 LinearLayout 是不可能的嗎? 任何幫助表示贊賞。
您應該使用以下方法添加頁腳:
list.addFooterView(footerView);
或手動執行,但考慮使用相對布局,比線性布局更強大。 然后將您的頁腳放在列表下方,或者更好的是,將您的列表和空視圖放在您的頁腳視圖上方。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.