View like android's contact screen

不问归期 提交于 2019-12-22 10:03:07

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/2684022/view-like-androids-contact-screen

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!