我试图把一个ListView下方的进度条查看了ListActivity。我希望它永远在ListView中的最后一行的下方。
I'm trying to put a ProgressBar view below a ListView for a ListActivity. I want it to be always below the last row in the listView.
的进度,它被放置在一个的LinearLayout,确实出现,只要该列表(这是由一个适配器在运行时填充)不超过屏幕。一旦列表比屏幕大,进度不再可见。
The ProgressBar, which is placed in a LinearLayout, does appear, as long as the list (which is filled by an adapter at runtime) is not exceeding the screen. As soon as the list is larger than the screen, the ProgressBar is no longer visible.
布局XML看起来是这样的:
The layout xml looks like this:
<?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中?任何帮助AP preciated。
Is this not possible with a LinearLayout? Any help appreciated.
您应该使用添加页脚:
list.addFooterView(footerView);
或做手工,但后来考虑使用相对布局,还有比直线布局更为强大。然后将你的页脚列表下方,或更好,把你的列表的和的你对你的footerview以上空视图。
or doing it manually, but then consider using relative layouts, there are far more powerfull than linear layouts. And then place your footer below the list, or better, place your list and your empty view above your footerview.