Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ListView populates from the bottom instead of from the top

I have a listView that expands upwards instead of downwards. I have another listView on another page that works just fine and populates itself from the top -> bot. Why does my listView start from the bottom instead of the top?

My XML `

<ListView
    android:id="@+id/list_view_showRegister"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_above="@+id/showRegister"
    android:layout_alignParentLeft="true"
    android:layout_marginTop="50dp"
    android:clickable="false" >

</ListView>`
like image 873
NiklasHansen Avatar asked Nov 07 '12 12:11

NiklasHansen


People also ask

How do I make a list view clickable?

How can you react to click events on an item of a ListView? Place an empty linearlayout below the listview by setting an appropriate height to the listview. Place an onClick() method to that linear layout. That must do it.

Which method is used to obtain the selected option from a ListView?

An API is used to get selected items from the list items. This is called as the getSelectedItems method.

What is ListView explain it using appropriate examples?

Android ListView is a view which groups several items and display them in vertical scrollable list. The list items are automatically inserted to the list using an Adapter that pulls content from a source such as an array or database.


1 Answers

Your ListView is still actually populating from the top downwards. Just not from the top of the page.

You have set the layout_height="wrap_content" and the layout_above="@+id/showRegister". With the height being wrap_content, the view will only be as large as it's contents. Then, due to the fact you have used layout_above, it will be directly above another view.

The listview is not filling from the bottom, it is filling from the top (of the listview) - but the listview itself is only starting from halfway up the screen. Anything above the listview is not actually part of the listview, but empty space instead.

The solution is to either set the layout_height="match_parent", or remove the layout_above tag.

I know this is an old question but I hope this helps anyone else who may have found this issue via google.

like image 111
Mike Baxter Avatar answered Sep 20 '22 13:09

Mike Baxter