如何在 Android ListView 的末尾显示按钮 [英] How to show a button at the end of an Android ListView

查看:22
本文介绍了如何在 Android ListView 的末尾显示按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 Android 列表视图的末尾显示一个按钮.我怎样才能做到这一点?

I want to show a button at the end of an Android list view. How can I achieve this?

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

I don't want to stick it to the activity bottom using alignparentbottom="true". Using layout_below does not work for me either.

我当前的 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()底部添加一个View>ListView.

You may want to use ListView#addFooterView() to add a View at the bottom of the ListView.

这篇关于如何在 Android ListView 的末尾显示按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆