创建简单的字母顺序滚动ListView中?字母、顺序、简单、ListView

2023-09-12 23:47:45 作者:把星星放进口袋里

我期待效仿在最新的音乐应用程序,即漂亮的小光标弹出它允许一个滚动超快速的艺术家/专辑/曲目,他们正在寻找的功能:

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做一些繁重的工作。还可以使用 setFastScrollEnabled(真)实际的ListView 来实现这一点。

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。你可以尝试寻找实施here并看到它如何努力将适应它的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.