Android Guides | Samples

Android.Widget.AlphabetIndexer Class

A helper class for adapters that implement the SectionIndexer interface.

See Also: AlphabetIndexer

Syntax

[Android.Runtime.Register("android/widget/AlphabetIndexer", DoNotGenerateAcw=true)]
public class AlphabetIndexer : DataSetObserver, ISectionIndexer, IDisposable

Remarks

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.

Your adapter is responsible for updating the cursor by calling AlphabetIndexer.SetCursor(ICursor) if the cursor changes. AlphabetIndexer.GetPositionForSection(Int32) method does the binary search for the starting index of a given section (alphabet).

[Android Documentation]

Requirements

Namespace: Android.Widget
Assembly: Mono.Android (in Mono.Android.dll)
Assembly Versions: 0.0.0.0
Since: Added in API level 3

The members of Android.Widget.AlphabetIndexer are listed below.

See Also: DataSetObserver

Public Constructors

Constructs the indexer.
Constructs the indexer.

Protected Constructors

A constructor used when creating managed representations of JNI objects; called by the runtime.

Protected Properties

MAlphabetICharSequence. The string of characters that make up the indexing sections.
MColumnIndexInt32. The index of the cursor column that this list is sorted on.
MDataCursorICursor. Cursor that is used by the adapter of the list view.
[read-only]
override
ThresholdClassIntPtr. This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.
[read-only]
override
ThresholdTypeType. This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

Public Methods

GetPositionForSection(Int32) : Int32
Performs a binary search or cache lookup to find the first row that matches a given section's starting letter.
GetSectionForPosition(Int32) : Int32
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.
GetSections() : Object[]
Returns the section array constructed from the alphabet provided in the constructor.
SetCursor(ICursor)
Sets a new cursor as the data set and resets the cache of indices.

Protected Methods

Compare(String, String) : Int32
Default implementation compares the first character of word with letter.