完整内容,请查看:http://www.zhdoc.net/android/reference/android/widget/AlphabetIndexer.html
AlphabetIndexer
public class AlphabetIndexer
extends DataSetObserver
implements SectionIndexer
java.lang.Object | ||
↳ | android.database.DataSetObserver | |
↳ | android.widget.AlphabetIndexer |
A helper class for adapters that implement the SectionIndexer interface. If the items in the adapter are sorted by simple alphabet-based sorting, then this class provides a way to do fast indexing of large lists using binary search. It caches the indices that have been determined through the binary search and also invalidates the cache if changes occur in the cursor.
用于实现SectionIndexer接口的适配器的辅助类。如果适配器中的项是通过简单的字母表顺序排序,则此类提供了使用二分法查找,以快速索引大型列表的方法。它缓存了通过二分法查找确定的索引,并且如果其中的游标发生更改,也会使缓存失效。
setCursor(Cursor)
来更新游标。
getPositionForSection(int)
方法对指定部分(字母表)的起始索引进行二分法查找。
摘要
字段 | |
---|---|
protected CharSequence | mAlphabet The string of characters that make up the indexing sections. |
protected int | mColumnIndex The index of the cursor column that this list is sorted on. |
protected Cursor | mDataCursor Cursor that is used by the adapter of the list view. |
Public构造方法 | |
---|---|
AlphabetIndexer(Cursor cursor, int sortedColumnIndex, CharSequence alphabet) Constructs the indexer. |
Public方法 | |
---|---|
int | getPositionForSection(int sectionIndex) Performs a binary search or cache lookup to find the first row that matches a given section's starting letter. |
int | getSectionForPosition(int position) Returns the section index for a given position in the list by querying the item and comparing it with all items in the section array. |
Object[] | getSections() Returns the section array constructed from the alphabet provided in the constructor. |