I have an ArrayList of items that are linked to a custom Adapter. The items are in alphabetical order. I would like my ListView to have a maximum of four items on each line of the ListView with the lines separated alphabetically.
For example:
[ Hi ] [ Hospital ] [ Hotel ] [ HotSpot ]
[ House ]
[ Impossible] [ Improbable ]
So multiple items would be on the same line of the ListView.
Is there a way to use the position variable within the custom Adapter class's getView() method to accomplish this?
Here is an example, sorry for the quality:
In the image, the backing store, such as ArrayList, would contain those names alphabetized.
You have to implement the CustomListView. on GetView method of the ArrayAdapter of your object.
See below Example:
See this link.
It will realy going to help you.
Enjoy. :)
Yes, in the getView( ) method one of the parameters is a position which can be used to send the relevant view back
public abstract View getView (int position, View convertView, ViewGroup parent)
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