android - 如何在 Android ListView 的末尾显示一个按钮

标签 android listview

我想在 Android ListView 的末尾显示一个按钮。我怎样才能做到这一点?

我不想使用 alignparentbottom="true" 将其粘贴到 Activity 底部。使用 layout_below 对我也不起作用。

我当前的 XML:

<?xml version="1.0" encoding="UTF-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/main_bg">

    <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content">

        <ListView
            android:id="@+id/android:list"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:drawSelectorOnTop="false"
            android:cacheColorHint="#ff6a00"
            android:divider="#ff8f40"
            android:dividerHeight="1px" />

    </LinearLayout>

    <RelativeLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
            android:layout_height="50sp"
        android:background="#676767"
        android:orientation="vertical">

        <Button
            android:layout_width="100px"
            android:layout_height="wrap_content"
            android:id="@+id/btnGetMoreResults"
            android:layout_marginLeft="10px"
            android:text="Get more" />

    </RelativeLayout>

</RelativeLayout>

最佳答案

您可能想使用 ListView#addFooterView()ListView 的底部添加一个 View

关于android - 如何在 Android ListView 的末尾显示一个按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2386593/

相关文章:

android - 我如何在 android 的 TextView 中添加查看更多/查看更少按钮

android - 为什么应用程序在尝试初始化 textview 时停止?

Android ListView 背景

java - 在 Android 上混合两个文件音频 wav 使用短数组

c++ - 为什么重画窗口后人物的影子还在那里?

Android水平滚动列表

android - Google play 游戏服务,确定主机或服务器

java - 如何在 listView 中同时左右对齐文本

c# - 选择 ListView 项时填充文本框

c# - ListView : InvalidArgument = Value of '0' is not valid for 'index' 中的错误