2013-10-16 42 views
0

我想添加一個視圖在列表視圖的底部作爲頁腳,但它的頂部。我嘗試了很多方法,但都是徒勞。頁腳沒有顯示在列表視圖的底部

這是我的XML ....包含ListView和頁腳包括

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="#EFEFEF" 
    android:padding="15dp" > 

    <ImageButton 
     android:id="@+id/btnDeleteUserInfo" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentRight="true" 
     android:layout_marginRight="70dp" 
     android:background="@android:color/transparent" 
     android:src="@drawable/manage_product_frag_delete" /> 

    <View 
     android:id="@+id/viewHorizontal" 
     android:layout_width="match_parent" 
     android:layout_height="1dp" 
     android:layout_below="@+id/btnDeleteUserInfo" 
     android:layout_marginTop="5dp" 
     android:background="#000000" /> 

    <ListView 
     android:id="@+id/lvUserInfo" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/viewHorizontal" 
     android:divider="#000000" 
     android:dividerHeight="1dp" > 
    </ListView> 

    <include 
     android:id="@+id/footer" 
     android:layout_below="@+id/lvUserInfo" 
     layout="@layout/administration_add_user_view" /> 

</RelativeLayout> 

這是代碼:

lvUserInfo = (ListView) layoutView.findViewById(R.id.lvUserInfo); 
    userInfoAdapter = new AdministrationUserInfoAdapter(getActivity()); 
    lvUserInfo.setAdapter(userInfoAdapter); 
    userInfoAdapter.addData(fillDataset()); 
    View footer=(View) layoutView.findViewById(R.id.footer); 
    lvUserInfo.addFooterView(footer, null,true); 

請幫助..我真的無法找到我在哪裏缺少

回答

1

嘗試這種佈局

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="#EFEFEF" 
    android:padding="15dp" 
    android:orientation="vertical" > 

    <ImageButton 
     android:id="@+id/btnDeleteUserInfo" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="right" 
     android:layout_marginRight="70dp" 
     android:background="@android:color/transparent" 
     android:src="@drawable/manage_product_frag_delete" /> 

    <View 
     android:id="@+id/viewHorizontal" 
     android:layout_width="match_parent" 
     android:layout_height="1dp" 
     android:layout_marginTop="5dp" 
     android:background="#000000" /> 

    <ListView 
     android:layout_weight="1" 
     android:id="@+id/lvUserInfo" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:divider="#000000" 
     android:dividerHeight="1dp" > 
    </ListView> 

    <include 
     layout="@layout/administration_add_user_view" /> 

</LinearLayout> 
+0

Thanx a ton .... its working :) – pioneerBhawna

0

試試這個佈局,

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:background="#EFEFEF" 
android:padding="15dp" > 

<ImageButton 
    android:id="@+id/btnDeleteUserInfo" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentRight="true" 
    android:layout_marginRight="70dp" 
    android:background="@android:color/transparent" 
    android:src="@drawable/manage_product_frag_delete" /> 

<include 
    android:id="@+id/footer" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    layout="@layout/tab_layout" /> 

<View 
    android:id="@+id/viewHorizontal" 
    android:layout_width="match_parent" 
    android:layout_height="1dp" 
    android:layout_below="@id/btnDeleteUserInfo" 
    android:layout_marginTop="5dp" 
    android:background="#000000" /> 

<ListView 
    android:id="@+id/lvUserInfo" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_above="@id/footer" 
    android:layout_below="@id/viewHorizontal" 
    android:divider="#000000" 
    android:dividerHeight="1dp" > 
</ListView> 

</RelativeLayout> 
0

你需要調整相對views.try這一個,它會工作。

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="#EFEFEF" 
    android:padding="15dp" > 

<RelativeLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_above="@+id/footer" 
    >  

    <ImageButton 
     android:id="@+id/btnDeleteUserInfo" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginRight="70dp" 
     android:background="@android:color/transparent" 
     android:src="@drawable/manage_product_frag_delete" /> 

    <View 
     android:id="@+id/viewHorizontal" 
     android:layout_width="match_parent" 
     android:layout_height="1dp" 
     android:layout_below="@+id/btnDeleteUserInfo" 
     android:layout_marginTop="5dp" 
     android:background="#000000" /> 

    <ListView 
     android:id="@+id/lvUserInfo" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/viewHorizontal" 
     android:divider="#000000" 
     android:dividerHeight="1dp" > 
    </ListView> 
</RelativeLayout>  

    <include 
    android:id="@+id/footer" 
    android:layout_alignParentBottom="true" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    layout="@layout/administration_add_user_view" /> 

</RelativeLayout> 

我希望它會有幫助!