如何显示在listactivity另一布局 [英] How to show another layout in listactivity
问题描述
我有一个包含一个ListView一个listactivity。我想说明,其中包含在顶部的按钮,并在底部在这个列表视图网页视图和布局总是显示另一个布局。我试过,但这个不是我想要做的:
I have a listactivity which contains a listview. i want to show another layout which contains a button at top and a webview at bottom on this listview and that layout always to be shown. I tried this but this is not what i want to do :
ListView lv =getListView();
LayoutInflater inflater = getLayoutInflater();
ViewGroup header = (ViewGroup)inflater.inflate(R.layout.mylayer, lv, false);
lv.addHeaderView(header, null, false);
这显示了我的布局,但是当我滚动列表视图我的,不用说,当我滚动列表视图我下来就没有更多的显示像它是我的其他物品列表视图的一部分。
This shows my layout but when i scroll my listview, needless to say that when i scroll my listview down it is no more to be shown like it is part of my other listview items.
推荐答案
在使用 ListActivity
,你可以使用任何你想要的布局。你必须按照合同仅是把一个的ListView
id为列表
。因此,你可以这样做:
When using ListActivity
, you can use any layout you want. The only contract you must follow is putting a ListView
whose id is list
. Thus, you can do something like:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:id="@+id/something"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:text="What ever"/>
<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="@+id/something"/>
</RelativeLayout>
如果你想重用另一个布局,改变的TextView
的东西像&LT;包括&GT;
(以看看这篇文章 )。
If you do want to reuse another layout, change the TextView
for something like <include>
(take a look at this article).
这篇关于如何显示在listactivity另一布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!