views:

54

answers:

1

i have content i need to display above my listview and below, so much that a scrollview would be great to use if you could use scrollviews and listviews together. Since thats not the best solution, i've been trying to do a couple of things to add footer content to my listview,

here the pic below shows what happens when i add a different type of row as the last row. I can't get my content to fill the width of the row

alt text

I have a couple of buttons that need to go in the footer. I'm using a custom adapter that extends BaseAdapter.

I have also tried using the addFooterView but i'm confused on how to use the addFooterView method if you are implementing your own adapter. Anyone have any simple examples of how to implement addFooterView on a custom adapter

or

is there a way i can get the row at this position (as seen in the picture ) to display better, here is the code i'm using to create this footer row

        View v = getLayoutInflater().inflate(R.layout.item_listview_footer, null);
        LinearLayout ll = (LinearLayout) v.findViewById(R.id.ll);
        return ll;  // return ll as convertView in getView function

edit:

here is the xml for my footer layout

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="wrap_content" android:layout_width="fill_parent" android:background="@drawable/red" android:orientation="vertical" android:id="@+id/ll">
    <Button android:id="@+id/specialInsButton" style="@style/button" android:text="Add Special Instructions" android:layout_width="fill_parent"/>
    <Button android:id="@+id/addToBagButton" style="@style/button" android:text="Add To Bag"/>
    <EditText android:id="@+id/quantity" style="@style/standard" android:text="1"/>
</LinearLayout>

here is the xml for style/button

<style name="button">
        <item name="android:layout_height">wrap_content</item>
        <item name="android:layout_width">fill_parent</item>
        <item name="android:textSize">17px</item>
        <item name="android:textStyle">bold</item>
        <item name="android:typeface">sans</item>
        <item name="android:gravity">center</item>
        <item name="android:layout_gravity">center</item>

    </style>

standard style

 <style name="standard">
        <item name="android:layout_height">wrap_content</item>
        <item name="android:layout_width">wrap_content</item>
    </style>
A: 

You can use addFooterView with a custom adapter. Just be sure to make the addFooterView call before the call to listview.setAdapter().

View v = getLayoutInflater().inflate(R.layout.item_listview_footer, null);
listView.addFooterView(v);
listView.setAdapter(adapter);
danh32
@danh32 that works fine but my footer view is still not showing properly, any ideas why its still only a few pixels wide instead of "fill_parent" wide ? ? ?
slim
I don't see anything that might be causing this. These buttons are supposed to be stacked vertically and take up the whole width of the screen, right? You should use 'sp' instead of 'px' in your textSize property, but that should be unrelated. Could you post @style/standard for the editText?
danh32
you're right, here's the style <style name="standard"> <item name="android:layout_height">wrap_content</item> <item name="android:layout_width">wrap_content</item> </style>
slim
Nothing seems wrong to me. Have you tried looking at the view using hierarchyViewer? It should help in finding which view is causing the error. http://developer.android.com/guide/developing/tools/hierarchy-viewer.html
danh32