下方滚动的ListView固定键 [英] Fixed Button below a scrollable ListView

查看:86
本文介绍了下方滚动的ListView固定键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个滚动的ListView与项目(如在<一个href="http://developer.android.com/resources/tutorials/views/hello-listview.html">http://developer.android.com/resources/tutorials/views/hello-listview.html).我使用的是 ArrayAdapter 的项目,并用它作为 setListAdapter 的参数。现在,我想补充一个按钮在屏幕上,不与滚动列表的底部。可能有人给我一些提示或张贴code段他们怎么可能做到?

I have a scrollable ListView with items (like in http://developer.android.com/resources/tutorials/views/hello-listview.html). I am using an ArrayAdapter for the items and use it as a parameter in setListAdapter. Now I would like to add a button at the bottom of the screen, which does not scroll with the list. Could someone give me some hints or post a code snippet how it could possibly be done?

推荐答案

如果你的活动扩展了ListActivity,那么你需要的是这样的:

If your activity extends ListActivity then you need something like this:

<LinearLayout android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:orientation="vertical">

<ListView android:id="@android:id/list"
          android:layout_height="0dip"
          android:layout_width="match_parent"
          android:layout_weight="1" />

<Button android:id="@+id/btn" 
        android:layout_width="match_parent"
        android:layout_height="wrap_content"/>

</LinearLayout>

请注意,该列表视图有一个layout_weight设置为1,将保持在底部固定在其位置的按钮。希望有所帮助。祝你好运!

Notice that the listview has a layout_weight set to 1. That will keep the button fixed in its place at the bottom. Hope that helps. Good luck!

这篇关于下方滚动的ListView固定键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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