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

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

问题描述

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

我不希望它坚持采用活动底 alignparentbottom =真正的。使用 layout_below 对我也不起作用。

我目前的XML:

 < XML版本=1.0编码=UTF-8&GT?;
< RelativeLayout的
    的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    机器人:方向=横向
    机器人:layout_width =FILL_PARENT
    机器人:layout_height =FILL_PARENT
    机器人:背景=@可绘制/ main_bg>

    <的LinearLayout
        的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
        机器人:方向=垂直
        机器人:layout_width =FILL_PARENT
        机器人:layout_height =WRAP_CONTENT>

        <的ListView
            机器人:ID =@ + ID / Android的:清单
            机器人:layout_width =FILL_PARENT
            机器人:layout_height =WRAP_CONTENT
            机器人:drawSelectorOnTop =假
            机器人:cacheColorHint =#ff6a00
            机器人:分隔=#ff8f40
            机器人:dividerHeight =1像素/>

    < / LinearLayout中>

    < RelativeLayout的
        的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
        机器人:layout_width =FILL_PARENT
            机器人:layout_height =50SP
        机器人:后台=#676767
        机器人:方向=垂直>

        <按钮
            机器人:layout_width =100像素
            机器人:layout_height =WRAP_CONTENT
            机器人:ID =@ + ID / btnGetMoreResults
            机器人:layout_marginLeft =10px的
            机器人:文本=更多/>

    < / RelativeLayout的>

< / RelativeLayout的>
 

解决方案

您可能需要使用<一个href="http://developer.android.com/reference/android/widget/ListView.html#addFooterView%28android.view.View,%20java.lang.Object,%20boolean%29">ListView#addFooterView()添加查看在底部的的ListView

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

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

My current 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>

解决方案

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

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

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