2013-03-01 63 views
2

我知道有很多類似的問題,但我沒有找到能夠幫助我的答案,所以這是我的問題。我已成功地做到這一點: AS IS列表活動的自定義佈局Android

但我想是這樣的: TO BE

所以我想在屏幕底部的固定按鈕。而我的佈局是一個ListActivity自定義佈局,它看起來像這樣:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" > 

<RelativeLayout 
    android:id="@+id/relativeLayout1" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:layout_alignParentLeft="true" 
    > 
<Button 
    android:id="@+id/button1" 
    android:layout_width="wrap_content" 
    android:layout_height="match_parent" 
    android:layout_weight="1" 
    android:text="Delete" /> 

<TextView 
    android:id="@+id/label" 
    android:layout_width="wrap_content" 
    android:layout_height="match_parent" 
    android:layout_toRightOf="@+id/button1" 
    android:text="@+id/label" 
    android:gravity="center" 
    android:textSize="20px" > 
</TextView> 

<ImageButton 
    android:id="@+id/rightArrow" 
    android:layout_width="wrap_content" 
    android:layout_height="fill_parent" 
    android:background="@null" 
    android:layout_alignParentRight="true" 
    android:src="@drawable/right_arrow" 
    /> 

回答

7

你貼上什麼樣子的名單列,而不是ListActivity自定義佈局。

從Android文檔中發現here

屏幕布局

ListActivity有包括在thecenter屏幕的單,全屏幕列表的默認佈局。但是,如果您願意,可以通過在onCreate()中使用setContentView()設置您自己的視圖佈局來自定義屏幕布局。要做到這一點,你自己的視圖必須包含一個ID爲「@android:id/list」的ListView對象(或者如果它在代碼中,則列表)