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 CharSequencemAlphabet

The string of characters that make up the indexing sections.
组成索引部分的字符串。

protected intmColumnIndex

The index of the cursor column that this list is sorted on.
被排序的这个列表的游标列的索引。

protected CursormDataCursor

Cursor that is used by the adapter of the list view.
由列表视图的适配器使用的游标。

Public构造方法

AlphabetIndexer(Cursor cursor, int sortedColumnIndex, CharSequence alphabet)

Constructs the indexer.
构造AlphabetIndexer。

Public方法

intgetPositionForSection(int sectionIndex)

Performs a binary search or cache lookup to find the first row that matches a given section's starting letter.
执行一个二分法查找或在缓存中查找,以查找与指定section的起始字母相匹配的第一行。

intgetSectionForPosition(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数组。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值