I am developing an application with a large number of elements that must be ordered alphabetically, and I’d like it to have the same look and feel as android’s contact list, That is
[Letter]
<contact>
<contact>
[Letter]
<contact>
<contact>
<contact>
etc.
Which is the best way to achieve this same layout? I’ve seen several tutorials concerning scrollable lists, but this is a bit different. I’ve looked a bit through android’s source code, but if anyone has the answer, it would save me a lot of time.
Thanks in advance.
You could use my
MergeAdapterfor that, either directly or as a basis for creating your own adapter that gives you your desired look.In a nutshell, you need to create a
ListAdapterthat handles both your contacts and your headings. You will wind up using different views for those, most likely, and there are methods you override onListAdapterto each Android about those. You might also elect to say that the headings are not “enabled”, meaning they will not respond to selection or click events.