查看像Android的接触屏幕屏幕、Android

2023-09-06 06:31:07 作者:不離不棄

我开发了大量的必须按字母顺序排列的元素的应用,我想它有相同的外观和感觉作为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的源$ C ​​$ C位,但如果任何人有答案,这将节省我很多时间。

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.