大家。 你能帮我设置 ListView 的页脚吗?我已经在布局中描述了页脚,然后:
View footer = getLayoutInflater().inflate(R.layout.bottom, getListView(), false);
getListView().addFooterView(footer);
但是没有出现... 能举个例子吗?我还需要动态设置页脚的高度。下面是页脚的代码:
<?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"
android:background="#87ceeb"
>
<TextView android:id="@+id/loading"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:textColor="#000000"
android:textStyle="bold"
android:text="Loading..."/>
</LinearLayout>
最佳答案
这可能有几个原因, 你添加代码了吗
getListView().addFooterView(页脚);在 ListView 的 setAdapter 之前?如果是。
xml布局可能有问题, 如果您的 ListView 是 wrap_content 并且您的页脚布局具有 fill_parent ,则页脚可能不会出现,除非您的页脚布局的 TextView 中有一些文本。
更改 ListView layout_width="fill_parent"和页脚布局的 layout_width="fill_parent"
要快速检查 ,请为您的页脚布局提供背景颜色并查看其位置。 希望对您有所帮助。
关于android - 将页脚设置为 ListView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5267823/