Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to show a button at the end of an Android ListView

I want to show a button at the end of an Android list view. How can I achieve this?

I don't want to stick it to the activity bottom using alignparentbottom="true". Using layout_below does not work for me either.

My current XML:

<?xml version="1.0" encoding="UTF-8"?> <RelativeLayout     xmlns:android="http://schemas.android.com/apk/res/android"     android:orientation="horizontal"     android:layout_width="fill_parent"     android:layout_height="fill_parent"     android:background="@drawable/main_bg">      <LinearLayout         xmlns:android="http://schemas.android.com/apk/res/android"         android:orientation="vertical"         android:layout_width="fill_parent"         android:layout_height="wrap_content">          <ListView             android:id="@+id/android:list"             android:layout_width="fill_parent"             android:layout_height="wrap_content"             android:drawSelectorOnTop="false"             android:cacheColorHint="#ff6a00"             android:divider="#ff8f40"             android:dividerHeight="1px" />      </LinearLayout>      <RelativeLayout         xmlns:android="http://schemas.android.com/apk/res/android"         android:layout_width="fill_parent"             android:layout_height="50sp"         android:background="#676767"         android:orientation="vertical">          <Button             android:layout_width="100px"             android:layout_height="wrap_content"             android:id="@+id/btnGetMoreResults"             android:layout_marginLeft="10px"             android:text="Get more" />      </RelativeLayout>  </RelativeLayout> 
like image 934
UMAR-MOBITSOLUTIONS Avatar asked Mar 05 '10 12:03

UMAR-MOBITSOLUTIONS


People also ask

How to add a button to a listview?

You must create custom ListAdapter for your ListView which will create a view with a Button in the getView method.

How to use listview in Android Studio?

ListView Tutorial With Example In Android Studio. Adapter: To fill the data in a ListView we simply use adapters. List items are automatically inserted to a list using an Adapter that pulls the content from a source such as an arraylist, array or database. ListView in Android Studio: Listview is present inside Containers.

How to scroll down listview automatically in Android?

Dynamically scroll down to bottom of listview move to last element on button click. Automatic listview scroll down feature mostly sees in chatting android apps like What’s App and Hike.

How do you insert an item into a list in Android?

List items are automatically inserted to a list using an Adapter that pulls the content from a source such as an arraylist, array or database. ListView in Android Studio: Listview is present inside Containers. From there you can drag and drop on virtual mobile screen to create it.


1 Answers

You may want to use ListView#addFooterView() to add a View at the bottom of the ListView.

like image 200
Diego Torres Milano Avatar answered Oct 04 '22 14:10

Diego Torres Milano