2013-10-20 73 views

回答

1

我以前也遇到過這個問題。在我的組件中,我想在Listview中添加一個下拉菜單來刷新功能。我所做的是聲明在XML佈局文件的視圖佈局,然後在我的ListView子類中,我使用下面的代碼:

this.addHeaderView(headerRelativeLayout, null, false); //this is the ListView sub class 

這裏是我的全部代碼:

private void init(Context context) { 
inflater = LayoutInflater.from(context); 
headerRelativeLayout = (RelativeLayout)inflate(context, R.layout.refresh_header_view, null); 
arrowImage = (ImageView)headerRelativeLayout.findViewById(R.id.head_arrowImageView); 
progressBar = (ProgressBar)headerRelativeLayout.findViewById(R.id.head_progressBar); 
headerTextView = (TextView)headerRelativeLayout.findViewById(R.id.head_tipsTextView); 
lastUpdateDateTextView = (TextView)headerRelativeLayout.findViewById(R.id.head_lastUpdatedDateTextView); 

headerRelativeLayout.setPadding(0, -1 * HEADER_HEIGHT, 0, 0); 
this.addHeaderView(headerRelativeLayout, null, false); 

}

對於更多的細節,你可以檢查這個:Drag to Refresh in ListView Android Example

3

LItem:= ListView.Items.Add; LItem.Purpose:= TListItemPurpose.Footer;

+0

永遠不要這樣回答,必須描述你的問題。在回答本網站之前,請閱讀FAQ – Hamad

0

試試這個

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:gravity="bottom|top" 
    android:orientation="vertical" > 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" 
     android:background="@color/background_bottom_bar" 
     > 

     <TextView 
     android:text="Header" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content"/> 
    </LinearLayout> 

    <GridView 
     android:id="@+id/gridview_practioner" 
     android:layout_width="fill_parent" 
     android:layout_height="match_parent" 
     android:columnWidth="90dp" 
     android:horizontalSpacing="10dp" 
     android:numColumns="5" 
     android:layout_weight="1" 
     android:stretchMode="columnWidth" 
     android:verticalSpacing="10dp" /> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" > 

    <TextView 
     android:text="Footer" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:background="@color/background_bottom_bar" 
     android:layout_gravity="bottom"/> 
    </LinearLayout> 
</LinearLayout> 

注:

這裏如果你正在使用的ListView或GridView控件,你必須給列表視圖或gridview的重量= 1。

相關問題