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>`
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.
An API is used to get selected items from the list items. This is called as the getSelectedItems method.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With