2011-02-02 55 views
1

我有一個listactivity包含一個列表視圖。我想顯示另一個佈局,其中包含頂部的按鈕和此列表視圖底部的webview,並且總是顯示佈局。我試過,但這個不是我想做的事:如何在列表中顯示另一個佈局

ListView lv =getListView(); 
LayoutInflater inflater = getLayoutInflater(); 
ViewGroup header = (ViewGroup)inflater.inflate(R.layout.mylayer, lv, false); 
lv.addHeaderView(header, null, false); 

這說明我的佈局,但是當我滾動我的列表視圖,不用說,當我滾動我的列表視圖下它已不再是要顯示喜歡它是我的其他listview項目的一部分。

回答

3

使用ListActivity時,您可以使用任何您想要的佈局。您必須遵循的唯一合同是放置一個ListView,其編號爲list。因此,你可以這樣做:

<?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這樣的事情<include>(看看this article)。

相關問題