So I have a listview and I want to add different "sections" to it. I understand how addHeaderView works and it's straight forward, but is there a way to add section headers? Like let's say I have an alphabetical list, is there a way to mark the top of each section of letters? The list is dynamic though, so I won't know when/where I'll need a section header until I get to that point.
+1
A:
Hi,
These section headers are called "separators" in Android lists. To specify that given entry in the list is a separator, you must modify your Adapter to return false
from isEnabled method for that position. It helps if you properly write the getItemViewType method, so you can have customized layout for separator entries.
ognian
2010-07-08 17:53:39
Hmm. I hacked my arraylist to insert null pointers where I wanted the separators, and then just returned a simple linearlayout and textview in my getView method if the object at that position is null.This is probably a much better way of doing it though and I'll look at this further tomorrow.
Falmarri
2010-07-12 07:51:13