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
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>
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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With