IT. Expert System.

Android Reference

AlphabetIndexer


android.widget

Class AlphabetIndexer

  • All Implemented Interfaces:
    SectionIndexer


    public class AlphabetIndexer
    extends DataSetObserver
    implements SectionIndexer
    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 setCursor(android.database.Cursor) if the cursor changes. getPositionForSection(int) method does the binary search for the starting index of a given section (alphabet).

    • Field Detail

      • mDataCursor

        protected Cursor mDataCursor
        Cursor that is used by the adapter of the list view.
      • mColumnIndex

        protected int mColumnIndex
        The index of the cursor column that this list is sorted on.
      • mAlphabet

        protected CharSequence mAlphabet
        The string of characters that make up the indexing sections.
    • Constructor Detail

      • AlphabetIndexer

        public AlphabetIndexer(Cursor cursor,
                       int sortedColumnIndex,
                       CharSequence alphabet)
        Constructs the indexer.
        Parameters:
        cursor - the cursor containing the data set
        sortedColumnIndex - the column number in the cursor that is sorted alphabetically
        alphabet - string containing the alphabet, with space as the first character. For example, use the string " ABCDEFGHIJKLMNOPQRSTUVWXYZ" for English indexing. The characters must be uppercase and be sorted in ascii/unicode order. Basically characters in the alphabet will show up as preview letters.
    • Method Detail

      • getSections

        public Object[] getSections()
        Returns the section array constructed from the alphabet provided in the constructor.
        Specified by:
        getSections in interface SectionIndexer
        Returns:
        the section array
      • setCursor

        public void setCursor(Cursor cursor)
        Sets a new cursor as the data set and resets the cache of indices.
        Parameters:
        cursor - the new cursor to use as the data set
      • compare

        protected int compare(String word,
                  String letter)
        Default implementation compares the first character of word with letter.
      • getPositionForSection

        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.
        Specified by:
        getPositionForSection in interface SectionIndexer
        Parameters:
        sectionIndex - the section to search for
        Returns:
        the row index of the first occurrence, or the nearest next letter. For instance, if searching for "T" and no "T" is found, then the first row starting with "U" or any higher letter is returned. If there is no data following "T" at all, then the list size is returned.
      • getSectionForPosition

        public 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.
        Specified by:
        getSectionForPosition in interface SectionIndexer
        Parameters:
        position - the position for which to return the section
        Returns:
        the section index. If the position is out of bounds, the section index must be clipped to fall within the size of the section array.


Content

Android Reference

Java basics

Java Enterprise Edition (EE)

Java Standard Edition (SE)

SQL

HTML

PHP

CSS

Java Script

MYSQL

JQUERY

VBS

REGEX

C

C++

C#

Design patterns

RFC (standard status)

RFC (proposed standard status)

RFC (draft standard status)

RFC (informational status)

RFC (experimental status)

RFC (best current practice status)

RFC (historic status)

RFC (unknown status)

IT dictionary

License.
All information of this service is derived from the free sources and is provided solely in the form of quotations. This service provides information and interfaces solely for the familiarization (not ownership) and under the "as is" condition.
Copyright 2016 © ELTASK.COM. All rights reserved.
Site is optimized for mobile devices.
Downloads: 265 / 158848944. Delta: 0.04998 с