在 ListView 中创建简单的按字母顺序滚动? [英] Create easy alphabetical scrolling in ListView?

查看:19
本文介绍了在 ListView 中创建简单的按字母顺序滚动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望模拟最新音乐应用程序中的功能,即弹出的漂亮小光标允许用户快速滚动到他们正在寻找的艺术家/专辑/曲目:

I'm looking to emulate the functionality in the latest Music app, namely the nice little cursor that pops up which allows one to scroll super fast to the artist/album/track they're looking for:

是否有一种方法可以在 Android SDK 的 ListView 中启用这样的功能?

Is there a method to enable functionality like this in a ListView in the Android SDK?

推荐答案

让你的列表适配器实现 SectionIndexer.音乐应用程序还利用 AlphabetIndexer 来完成一些繁重的工作.还可以在实际的 ListView 上使用 setFastScrollEnabled(true) 来启用它.

Have your list adapter implement SectionIndexer. The music app also makes use of AlphabetIndexer to do some of the heavy lifting. Also use setFastScrollEnabled(true) on the actual ListView to enable this.

编辑:如果您不使用 CursorAdapter,您将无法使用 AlphabetIndexer.您可以尝试查看实现 这里 看看让它与 ArrayAdapter 一起工作有多难.

Edit: If you're not using a CursorAdapter, you won't be able to use AlphabetIndexer. You might try looking at the implementation here and seeing how hard it would be to adapt it to work with an ArrayAdapter.

这篇关于在 ListView 中创建简单的按字母顺序滚动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆