I need to place an item below a listview.
So far I have a Linearlayout containing a spinner that sits on top of a listview. Being in a LinearLayout, it stays fixed and below it I have a Listview which moves down and up. So far it is like this:
What I want now is, to put the LinearLayout that contains the spinners so that it appears below the listview but it is not fixed as it is now, but it appears below the last element of the listview.
This is how I now have the layout of this activity:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="net.pablo.android.app.acciones_lora_activity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/capaMedida"
android:orientation="vertical"
android:background="@drawable/selector_fieldset_background"
>
<Space
android:layout_width="match_parent"
android:layout_height="25dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<Spinner
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/spinnerComp1"
android:entries="@array/compuertasLora"
android:spinnerStyle="@android:style/Widget.Spinner.DropDown">
</Spinner>
<Spinner
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/spinnerC1"
android:entries="@array/accionesMedidaLora"
android:spinnerStyle="@android:style/Widget.Spinner.DropDown">
</Spinner>
</LinearLayout>
<Space
android:layout_width="match_parent"
android:layout_height="5dp"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Spinner
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/spinnerComp2"
android:entries="@array/compuertasLora"
android:spinnerStyle="@android:style/Widget.Spinner.DropDown">
</Spinner>
<Spinner
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/spinnerC2"
android:entries="@array/accionesMedidaLora"
android:spinnerStyle="@android:style/Widget.Spinner.DropDown">
</Spinner>
</LinearLayout>
<Space
android:layout_width="match_parent"
android:layout_height="5dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Spinner
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/spinnerComp3"
android:entries="@array/compuertasLora"
android:spinnerStyle="@android:style/Widget.Spinner.DropDown">
</Spinner>
<Spinner
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/spinnerC3"
android:entries="@array/accionesMedidaLora"
android:spinnerStyle="@android:style/Widget.Spinner.DropDown">
</Spinner>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/btn_accionesMedida"
android:text="Enviar accion"/>
<android.support.v4.widget.Space
android:layout_width="5dp"
android:layout_height="10dp"
android:id="@+id/espacio"
android:layout_below="@+id/btn_accionesMedida"/>
</LinearLayout>
</LinearLayout>
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:background="@drawable/selector_fieldset_background"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:text="Acciones a medida"
android:textAppearance="?android:attr/textAppearance"/>
<ListView
android:id="@+id/mi_lista"
android:layout_below="@+id/capaMedida"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
There is a method called
ListView#addFooterView(view)
that adds a view to the end of the list.Create an xml file in the folder
layout
and add the content of the view you want to add to the end. So when you initialize the list, you inflate the view and add it with the methodaddFooterView
: