问题描述
我正在开发一个具有大量必须按字母顺序排序的元素的应用程序,我希望它具有与android的联系人列表相同的外观,即
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>
等
哪种是实现相同布局的最佳方法?我看过几本有关可滚动列表的教程,但这有些不同.我已经仔细查看了android的源代码,但是如果有人得到了答案,它将为我节省很多时间.
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.
谢谢.
推荐答案
您可以使用我的 为此,可以直接使用MergeAdapter
或将其作为创建自己的适配器以提供所需外观的基础.
You could use my MergeAdapter
for that, either directly or as a basis for creating your own adapter that gives you your desired look.
简而言之,您需要创建一个同时处理您的联系人和标题的 ListAdapter
.您很可能会针对这些视图使用不同的视图,并且您会在 ListAdapter
上为每个Android覆盖有关这些视图的方法.您可能还选择说标题未启用",这意味着它们将不响应选择或单击事件.
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.
这篇关于像android的联系人屏幕一样查看的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!