我想在 ListActivity
的 ListView
下添加一个 ImageView
。这样当用户滚动到列表末尾时,ImageView
就会显示。
我似乎无法使我的布局正确。 ImageView
根本不显示,或者如果我使用 layout_weights,则 ListView
和 ImageView
都占据屏幕的 50%。有什么想法可以得到我想要的吗?谢谢。
<?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" >
<ListView
android:id="@+id/android:list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<TextView
android:id="@+id/android:empty"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/list_no_items" />
<ImageView
android:id="@+id/instruct_image"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="@drawable/instructions"/>
</LinearLayout>
最佳答案
不幸的是,我认为使用标准 Android 布局无法轻松完成您想要完成的任务。您不能在另一个 ScrollView
中包含一个 ListView
。
您可以使用 ListView
页脚将 ImageView
置于 ListView 下方。
或者,您可以尝试将 ImageView
添加为 ListView 的最后一行。为此,覆盖适配器的 getView
方法并返回 ImageView
(如果它是最后一行)。
关于android - 将 ImageView 添加到 ListActivity,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4893959/