I understand your question. Create a layout with a ListView
and create another layout with a button. Now add the Button
layout as a footer of this ListView
layout.
ListView Layout will be like this
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<ListView
android:id="@+id/myListView"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</RelativeLayout>
Now the Button Layout is
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<Button
android:id="@+id/myButton"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</RelativeLayout>
You can dynamically add footer in a ListView
. It is perfect solution for you. Checkout the answer How to add footer in Listview
For your purpose I can re-write the code as a sample. Please check it and play with it.
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:id="@+id/layoutOption1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:visibility="visible" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Item 1" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Item 2" />
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="My Button" />
</LinearLayout>
<LinearLayout
android:id="@+id/layoutOption2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:visibility="gone" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Item 1" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Item 2" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Item 3" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Item 4" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Item 5" />
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="My Button" />
</LinearLayout>
<LinearLayout
android:id="@+id/layoutOption3"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:visibility="gone" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Item 1" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Item 2" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Item 3" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Item 4" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Item 5" />
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="My Button" />
</LinearLayout>
</RelativeLayout>
</ScrollView>
In your activity class get the id of each layout option and setVisibility for your purpose. In your requirement I wrote this code for your. Thanks.