I've a ListView with items containing information about places with a rating and the distance to the current location.
The items are sorted into groups:
Withing these groups the items are sorted by their rating.
Now I put out these items via my custom adapter (extension of BaseAdapter
) into the ListView
, which works perfectly.
However, what I'd like to do is to put a separator before the each first item of each group. This separator can be a TextView
saying e.g. 500m - 1km followed by all the ListView
items in that group.
Any idea on how to realize this?
Here is one implementation that does exactly what you describe.
That one is GPLv3, because it is derived from this implementation, which was GPLv3.
You can also use my MergeAdapter
for this, which has the advantage of being Apache License 2.0. Just hand it an alternating set of header TextView
s and Adapter
s containing each section's worth of content.
Or, you can peek at all of these and roll their behaviors into your existing Adapter
class. The trick is to return your TextView
headers at the right spot, and properly implement methods like getViewTypeCount()
, getItemViewType()
, areAllItemsEnabled()
, and isEnabled()
.
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