2014-03-07 21 views
3
<ListView 
    android:id="@+id/listContact" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:headerDividersEnabled="true" 
    android:footerDividersEnabled="true" 
    android:dividerHeight="10dp" 
    android:background="@drawable/background" 
    android:divider="@drawable/background" 
    android:paddingLeft="10dp" 
    android:paddingRight="10dp" 
    android:fastScrollEnabled="true" 
    android:scrollingCache="true" 
    > 
</ListView> 

<Button 
     android:id="@+id/btnContactPostYourEnquiry" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:text="POST YOUR ENQUIRY" 
     android:background="@drawable/contact_post" 
     android:textColor="@color/White" 
     android:layout_margin="10dp" 
     android:layout_below="@+id/listContact"/> 

我嘗試在列表視圖中到底要不要屏幕的結尾顯示PastEnqury按鈕,但產量只有列表視圖是,如果列表項是更即列表視圖必須滾動 我書面方式驗證碼顯示按鈕不顯示在相對佈局如何修復Listview項目末尾的按鈕完成?

+1

刪除'RelativeLayout'把你的'ListView'和'Button'在'FrameLayout'和設置按鈕'Gravity'爲'Bottom' –

+5

DownVoters提到的原因,你的向下投票 –

+0

添加按鈕作爲頁腳到列表視圖 – Raghunandan

回答

0

我加入列表頁腳視圖

layout_contact_list.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="wrap_content" 
android:gravity="fill_vertical" 
android:layout_marginBottom="@dimen/action_button" > 

<ListView 
    android:id="@+id/listContact" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:background="@drawable/background" 
    android:divider="@drawable/background" 
    android:dividerHeight="10dp" 
    android:fastScrollEnabled="true" 
    android:footerDividersEnabled="true" 
    android:headerDividersEnabled="true" 
    android:paddingLeft="10dp" 
    android:paddingRight="10dp" 
    android:scrollingCache="true" > 

</ListView> 

contact_footer_view.xml

解決問題
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
> 

<Button 
     android:id="@+id/btnContactPostYourEnquiry" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:text="POST YOUR ENQUIRY" 
     android:background="@drawable/contact_post" 
     android:textColor="@color/White" 
     android:layout_margin="10dp" 
     android:padding="10dp" 
     android:layout_gravity="center_horizontal" 
     /> 

mainActivity.java

ListView list_Contact=(ListView)findViewById(R.id.listContact); 

    FrameLayout footerLayout = (FrameLayout) getLayoutInflater().inflate(R.layout.contact_footer_view,null); 
    Button btnPostYourEnquiry = (Button) footerLayout.findViewById(R.id.btnContactPostYourEnquiry); 
    list_Contact.addFooterView(footerLayout); 
0

只需使用Button作爲ListView頁腳。這樣,它將成爲ListView的一部分,您可以向下滾動到它。

+0

謝謝我的問題是通過addind footerView解決列表 – SAndroidD

+0

如果解決了您的問題,您是否將其標記爲解決方案?這樣,來這個網站的人就更容易了。 – akohout

0

把它放在相對佈局例如,在下面android:layout_above="@+id/linear"這段代碼給出會把你的ListView上述以外的佈局,只是ListView控件取代ExpandableListView

<RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:background="#000000" 
     android:orientation="horizontal" > 
    <ExpandableListView 
     android:id="@+id/lvExp" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:cacheColorHint="#00000000" 
     android:layout_above="@+id/linear" 
     android:groupIndicator="@null" /> 

    <LinearLayout 
     android:id="@+id/linear" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentLeft="true" 
     android:weightSum="1" 
     android:layout_marginLeft="30dp" 
     android:layout_marginRight="30dp" 
     android:orientation="horizontal" > 
</LinearLayout> 
    </RelativeLayout> 
+0

我得到的錯誤,自定義適配器不能設置爲ExpandableListView – SAndroidD

+0

更改ExpandableListView到xml中的ListView –

+0

但我的問題不能解決...請幫助:( – SAndroidD

0

Programetically設置列表視圖

的高度,例如LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams( LayoutParams.MATCH_PARENT,your_array.size()* 120);

次在XML中的線性佈局添加按鈕波紋管的ListView

+0

可以ü請給示例代碼 – SAndroidD