Maragues
Maragues

Reputation: 38324

View like android's contact screen

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.

Upvotes: 3

Views: 2373

Answers (1)

CommonsWare
CommonsWare

Reputation: 1006564

You could use my MergeAdapter for 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 ListAdapter that handles both your contacts and your headings. You will wind up using different views for those, most likely, and there are methods you override on ListAdapter to 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.

Upvotes: 3

Related Questions