neu242
neu242

Reputation: 16575

How do I make a Button a part of a scrollable ListView?

I have a ListView with a Button below it. When I fill the list with more content than the screen size allows, so that the scroll bar appears, the Button is not part of the scrollable area. That is, the Button disappears. How do I make the Button part of the scrollable area?

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <ListView android:id="@+id/ListView" android:layout_width="fill_parent"
        android:layout_height="wrap_content" android:layout_above="@+id/AddButton" />

    <Button android:id="@+id/AddButton" android:layout_width="fill_parent" 
        android:layout_height="wrap_content" android:text="@string/add_title" />
</RelativeLayout>

Upvotes: 1

Views: 288

Answers (2)

Robby Pond
Robby Pond

Reputation: 73484

Add it with addFooterView(). This way it will always appear at the bottom of the screen while the ListView still scrolls.

Upvotes: 2

ognian
ognian

Reputation: 11541

Add it to the ListView as footer.

Upvotes: 2

Related Questions