I have an issues, I want to show 20 items in the list. But there is a catch: if the user scrolls down to the bottom of the list, there will be an item that says: "Show more items", and when the users click on it, more items will be added to the list.
My question is how is poosible to have a last item, that has a different style and looks different: and does different things,(I think this is used in QuickSearchbox)
If you still want a clickable item rather than an infinitely scrolling list you can try using ListView#addFooterView
to add your "Show more items" item. This lets you add a view as the last item in a list. Make sure you call it before calling setAdapter
.
I would recommend you commonsware's cwac-endless.
cwac-endless: Provides the EndlessAdapter, a wrapper for an existing ListAdapter that adds "endless list" capability. When the user scrolls to the bottom of the list, if there is more data for this list to be retrieved, your code gets invoked in a background thread to fetch the new rows, which then get seamlessly attached to the bottom of the list.
While commonware has some awesome stuff. His endless lib may not be what you want. What you probably want is a footer. On your ListView, before you set your adapter, call addFooterView. Note that if you do that, the adapter you get from ListView.getAdapter will not be the same as what you passed to ListView.setAdapter.
Edit Speaking of commonware, he sells a few books on his site. Buy them. They are the best $40 you will spend on your android education.
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