Added in API level 3

SectionIndexer

interface SectionIndexer
android.widget.SectionIndexer

Interface that may implemented on Adapters to enable fast scrolling between sections of an AbsListView.

A section is a group of list items that have something in common. For example, they may begin with the same letter or they may be songs from the same artist.

ExpandableListAdapters that consider groups and sections as synonymous should account for collapsed groups and return an appropriate section/position.

Summary

Public methods
abstract Int
getPositionForSection(sectionIndex: Int)

Given the index of a section within the array of section objects, returns the starting position of that section within the adapter.

abstract Int

Given a position within the adapter, returns the index of the corresponding section within the array of section objects.

abstract Array<Any!>!

Returns an array of objects representing sections of the list.

Public methods

getPositionForSection

Added in API level 3
abstract fun getPositionForSection(sectionIndex: Int): Int

Given the index of a section within the array of section objects, returns the starting position of that section within the adapter.

If the section's starting position is outside of the adapter bounds, the position must be clipped to fall within the size of the adapter.

Parameters
sectionIndex Int: the index of the section within the array of section objects
Return
Int the starting position of that section within the adapter, constrained to fall within the adapter bounds

getSectionForPosition

Added in API level 3
abstract fun getSectionForPosition(position: Int): Int

Given a position within the adapter, returns the index of the corresponding section within the array of section objects.

If the section index is outside of the section array bounds, the index must be clipped to fall within the size of the section array.

For example, consider an indexer where the section at array index 0 starts at adapter position 100. Calling this method with position 10, which is before the first section, must return index 0.

Parameters
position Int: the position within the adapter for which to return the corresponding section index
Return
Int the index of the corresponding section within the array of section objects, constrained to fall within the array bounds

getSections

Added in API level 3
abstract fun getSections(): Array<Any!>!

Returns an array of objects representing sections of the list. The returned array and its contents should be non-null.

The list view will call toString() on the objects to get the preview text to display while scrolling. For example, an adapter may return an array of Strings representing letters of the alphabet. Or, it may return an array of objects whose toString() methods return their section titles.

Return
Array<Any!>! the array of section objects