Android7.0中文文档(API)-- AlphabetIndexer

完整内容,请查看: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.
构造AlphabetIndexer。

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.
执行一个二分法查找或在缓存中查找,以查找与指定section的起始字母相匹配的第一行。

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.
通过查询项并将其与section数组中的所有项进行比较,返回列表中指定位置的section索引。

Object[] getSections()

Returns the section array constructed from the alphabet provided in the constructor.
返回构造函数中所提供的字母表的section数组。

你可能感兴趣的:(android中文文档,android7.0中文API)