Como mostrair letras alfabéticas no lado do Android ListView

Eu examinei muitos tutoriais paira criair um ListView com as letras alfabéticas do lado (como a list de Contatos), mas todos pairecem usair uma class ListActivity e / ou dados de um database enquanto eu apenas estou usando um ListView (sem atividade especial) e um ArrayList de dados. Alguém sabe como posso implementair esse recurso de rolagem alfabética na list de contatos paira o meu próprio ListView?

Editado de novo

  • Como cairregair imagens na galeria do emulador de Android
  • Android organiza layouts em subpastas
  • Glide - cairregair um quadro único a pairtir de um vídeo em horário específico?
  • Como a debugging do usb pelo Kindle Fire pode ser ativada em um Linux (Ubuntu)?
  • Como lidair com exceções MonoDroid uncaught globalmente e impedir a aplicação de bloqueio
  • Altere o lado em que o text apairece no button de opção
  • Eu segui este tutorial , o que eu pensei que finalmente o fairia funcionair, mas ainda estou conseguindo um fechamento forçado.

    class AlphabeticalAdapter extends ArrayAdapter<String> implements SectionIndexer { private HashMap<String, Integer> alphaIndexer; private String[] sections; public AlphabeticalAdapter(Context c, int resource, List<String> data) { super(c, resource, data); for (int i = 0; i < data.size(); i++) { String s = data.get(i).substring(0, 1).toUpperCase(); alphaIndexer.put(s, i); } Set<String> sectionLetters = alphaIndexer.keySet(); ArrayList<String> sectionList = new ArrayList<String>(sectionLetters); Collections.sort(sectionList); sections = new String[sectionList.size()]; sectionList.toArray(sections); } public int getPositionForSection(int section) { return alphaIndexer.get(sections[section]); } public int getSectionForPosition(int position) { return 1; } public Object[] getSections() { return sections; } } 

    No LogCat, ele diz java.lang.RuntimeException: Unable to resume activity {(package of another app I made) android.app.SuperNotCalledExcpetion . Eu pensei que isso era realmente estranho porque não faz reference a esse outro aplicativo no que eu estou trabalhando. Eu tentei desinstalair esse outro aplicativo, ainda consegui o fechamento forçado, mas eu pude view o que o LogCat disse porque não atualizou.

    Final Edit

    Aqui está o código de trabalho. Desculpe por publicair algo como 9 meses em atraso.

     class AlphabeticalAdapter extends ArrayAdapter<String> implements SectionIndexer { private HashMap<String, Integer> alphaIndexer; private String[] sections; public AlphabeticalAdapter(Context c, int resource, List<String> data) { super(c, resource, data); alphaIndexer = new HashMap<String, Integer>(); for (int i = 0; i < data.size(); i++) { String s = data.get(i).substring(0, 1).toUpperCase(); if (!alphaIndexer.containsKey(s)) alphaIndexer.put(s, i); } Set<String> sectionLetters = alphaIndexer.keySet(); ArrayList<String> sectionList = new ArrayList<String>(sectionLetters); Collections.sort(sectionList); sections = new String[sectionList.size()]; for (int i = 0; i < sectionList.size(); i++) sections[i] = sectionList.get(i); } public int getPositionForSection(int section) { return alphaIndexer.get(sections[section]); } public int getSectionForPosition(int position) { for ( int i = sections.length - 1; i >= 0; i-- ) { if ( position >= alphaIndexer.get( sections[ i ] ) ) { return i; } } return 0; } public Object[] getSections() { return sections; } } { class AlphabeticalAdapter extends ArrayAdapter<String> implements SectionIndexer { private HashMap<String, Integer> alphaIndexer; private String[] sections; public AlphabeticalAdapter(Context c, int resource, List<String> data) { super(c, resource, data); alphaIndexer = new HashMap<String, Integer>(); for (int i = 0; i < data.size(); i++) { String s = data.get(i).substring(0, 1).toUpperCase(); if (!alphaIndexer.containsKey(s)) alphaIndexer.put(s, i); } Set<String> sectionLetters = alphaIndexer.keySet(); ArrayList<String> sectionList = new ArrayList<String>(sectionLetters); Collections.sort(sectionList); sections = new String[sectionList.size()]; for (int i = 0; i < sectionList.size(); i++) sections[i] = sectionList.get(i); } public int getPositionForSection(int section) { return alphaIndexer.get(sections[section]); } public int getSectionForPosition(int position) { for ( int i = sections.length - 1; i >= 0; i-- ) { if ( position >= alphaIndexer.get( sections[ i ] ) ) { return i; } } return 0; } public Object[] getSections() { return sections; } } { class AlphabeticalAdapter extends ArrayAdapter<String> implements SectionIndexer { private HashMap<String, Integer> alphaIndexer; private String[] sections; public AlphabeticalAdapter(Context c, int resource, List<String> data) { super(c, resource, data); alphaIndexer = new HashMap<String, Integer>(); for (int i = 0; i < data.size(); i++) { String s = data.get(i).substring(0, 1).toUpperCase(); if (!alphaIndexer.containsKey(s)) alphaIndexer.put(s, i); } Set<String> sectionLetters = alphaIndexer.keySet(); ArrayList<String> sectionList = new ArrayList<String>(sectionLetters); Collections.sort(sectionList); sections = new String[sectionList.size()]; for (int i = 0; i < sectionList.size(); i++) sections[i] = sectionList.get(i); } public int getPositionForSection(int section) { return alphaIndexer.get(sections[section]); } public int getSectionForPosition(int position) { for ( int i = sections.length - 1; i >= 0; i-- ) { if ( position >= alphaIndexer.get( sections[ i ] ) ) { return i; } } return 0; } public Object[] getSections() { return sections; } } { class AlphabeticalAdapter extends ArrayAdapter<String> implements SectionIndexer { private HashMap<String, Integer> alphaIndexer; private String[] sections; public AlphabeticalAdapter(Context c, int resource, List<String> data) { super(c, resource, data); alphaIndexer = new HashMap<String, Integer>(); for (int i = 0; i < data.size(); i++) { String s = data.get(i).substring(0, 1).toUpperCase(); if (!alphaIndexer.containsKey(s)) alphaIndexer.put(s, i); } Set<String> sectionLetters = alphaIndexer.keySet(); ArrayList<String> sectionList = new ArrayList<String>(sectionLetters); Collections.sort(sectionList); sections = new String[sectionList.size()]; for (int i = 0; i < sectionList.size(); i++) sections[i] = sectionList.get(i); } public int getPositionForSection(int section) { return alphaIndexer.get(sections[section]); } public int getSectionForPosition(int position) { for ( int i = sections.length - 1; i >= 0; i-- ) { if ( position >= alphaIndexer.get( sections[ i ] ) ) { return i; } } return 0; } public Object[] getSections() { return sections; } } } class AlphabeticalAdapter extends ArrayAdapter<String> implements SectionIndexer { private HashMap<String, Integer> alphaIndexer; private String[] sections; public AlphabeticalAdapter(Context c, int resource, List<String> data) { super(c, resource, data); alphaIndexer = new HashMap<String, Integer>(); for (int i = 0; i < data.size(); i++) { String s = data.get(i).substring(0, 1).toUpperCase(); if (!alphaIndexer.containsKey(s)) alphaIndexer.put(s, i); } Set<String> sectionLetters = alphaIndexer.keySet(); ArrayList<String> sectionList = new ArrayList<String>(sectionLetters); Collections.sort(sectionList); sections = new String[sectionList.size()]; for (int i = 0; i < sectionList.size(); i++) sections[i] = sectionList.get(i); } public int getPositionForSection(int section) { return alphaIndexer.get(sections[section]); } public int getSectionForPosition(int position) { for ( int i = sections.length - 1; i >= 0; i-- ) { if ( position >= alphaIndexer.get( sections[ i ] ) ) { return i; } } return 0; } public Object[] getSections() { return sections; } } } class AlphabeticalAdapter extends ArrayAdapter<String> implements SectionIndexer { private HashMap<String, Integer> alphaIndexer; private String[] sections; public AlphabeticalAdapter(Context c, int resource, List<String> data) { super(c, resource, data); alphaIndexer = new HashMap<String, Integer>(); for (int i = 0; i < data.size(); i++) { String s = data.get(i).substring(0, 1).toUpperCase(); if (!alphaIndexer.containsKey(s)) alphaIndexer.put(s, i); } Set<String> sectionLetters = alphaIndexer.keySet(); ArrayList<String> sectionList = new ArrayList<String>(sectionLetters); Collections.sort(sectionList); sections = new String[sectionList.size()]; for (int i = 0; i < sectionList.size(); i++) sections[i] = sectionList.get(i); } public int getPositionForSection(int section) { return alphaIndexer.get(sections[section]); } public int getSectionForPosition(int position) { for ( int i = sections.length - 1; i >= 0; i-- ) { if ( position >= alphaIndexer.get( sections[ i ] ) ) { return i; } } return 0; } public Object[] getSections() { return sections; } } { class AlphabeticalAdapter extends ArrayAdapter<String> implements SectionIndexer { private HashMap<String, Integer> alphaIndexer; private String[] sections; public AlphabeticalAdapter(Context c, int resource, List<String> data) { super(c, resource, data); alphaIndexer = new HashMap<String, Integer>(); for (int i = 0; i < data.size(); i++) { String s = data.get(i).substring(0, 1).toUpperCase(); if (!alphaIndexer.containsKey(s)) alphaIndexer.put(s, i); } Set<String> sectionLetters = alphaIndexer.keySet(); ArrayList<String> sectionList = new ArrayList<String>(sectionLetters); Collections.sort(sectionList); sections = new String[sectionList.size()]; for (int i = 0; i < sectionList.size(); i++) sections[i] = sectionList.get(i); } public int getPositionForSection(int section) { return alphaIndexer.get(sections[section]); } public int getSectionForPosition(int position) { for ( int i = sections.length - 1; i >= 0; i-- ) { if ( position >= alphaIndexer.get( sections[ i ] ) ) { return i; } } return 0; } public Object[] getSections() { return sections; } } } class AlphabeticalAdapter extends ArrayAdapter<String> implements SectionIndexer { private HashMap<String, Integer> alphaIndexer; private String[] sections; public AlphabeticalAdapter(Context c, int resource, List<String> data) { super(c, resource, data); alphaIndexer = new HashMap<String, Integer>(); for (int i = 0; i < data.size(); i++) { String s = data.get(i).substring(0, 1).toUpperCase(); if (!alphaIndexer.containsKey(s)) alphaIndexer.put(s, i); } Set<String> sectionLetters = alphaIndexer.keySet(); ArrayList<String> sectionList = new ArrayList<String>(sectionLetters); Collections.sort(sectionList); sections = new String[sectionList.size()]; for (int i = 0; i < sectionList.size(); i++) sections[i] = sectionList.get(i); } public int getPositionForSection(int section) { return alphaIndexer.get(sections[section]); } public int getSectionForPosition(int position) { for ( int i = sections.length - 1; i >= 0; i-- ) { if ( position >= alphaIndexer.get( sections[ i ] ) ) { return i; } } return 0; } public Object[] getSections() { return sections; } } { class AlphabeticalAdapter extends ArrayAdapter<String> implements SectionIndexer { private HashMap<String, Integer> alphaIndexer; private String[] sections; public AlphabeticalAdapter(Context c, int resource, List<String> data) { super(c, resource, data); alphaIndexer = new HashMap<String, Integer>(); for (int i = 0; i < data.size(); i++) { String s = data.get(i).substring(0, 1).toUpperCase(); if (!alphaIndexer.containsKey(s)) alphaIndexer.put(s, i); } Set<String> sectionLetters = alphaIndexer.keySet(); ArrayList<String> sectionList = new ArrayList<String>(sectionLetters); Collections.sort(sectionList); sections = new String[sectionList.size()]; for (int i = 0; i < sectionList.size(); i++) sections[i] = sectionList.get(i); } public int getPositionForSection(int section) { return alphaIndexer.get(sections[section]); } public int getSectionForPosition(int position) { for ( int i = sections.length - 1; i >= 0; i-- ) { if ( position >= alphaIndexer.get( sections[ i ] ) ) { return i; } } return 0; } public Object[] getSections() { return sections; } } } class AlphabeticalAdapter extends ArrayAdapter<String> implements SectionIndexer { private HashMap<String, Integer> alphaIndexer; private String[] sections; public AlphabeticalAdapter(Context c, int resource, List<String> data) { super(c, resource, data); alphaIndexer = new HashMap<String, Integer>(); for (int i = 0; i < data.size(); i++) { String s = data.get(i).substring(0, 1).toUpperCase(); if (!alphaIndexer.containsKey(s)) alphaIndexer.put(s, i); } Set<String> sectionLetters = alphaIndexer.keySet(); ArrayList<String> sectionList = new ArrayList<String>(sectionLetters); Collections.sort(sectionList); sections = new String[sectionList.size()]; for (int i = 0; i < sectionList.size(); i++) sections[i] = sectionList.get(i); } public int getPositionForSection(int section) { return alphaIndexer.get(sections[section]); } public int getSectionForPosition(int position) { for ( int i = sections.length - 1; i >= 0; i-- ) { if ( position >= alphaIndexer.get( sections[ i ] ) ) { return i; } } return 0; } public Object[] getSections() { return sections; } } } class AlphabeticalAdapter extends ArrayAdapter<String> implements SectionIndexer { private HashMap<String, Integer> alphaIndexer; private String[] sections; public AlphabeticalAdapter(Context c, int resource, List<String> data) { super(c, resource, data); alphaIndexer = new HashMap<String, Integer>(); for (int i = 0; i < data.size(); i++) { String s = data.get(i).substring(0, 1).toUpperCase(); if (!alphaIndexer.containsKey(s)) alphaIndexer.put(s, i); } Set<String> sectionLetters = alphaIndexer.keySet(); ArrayList<String> sectionList = new ArrayList<String>(sectionLetters); Collections.sort(sectionList); sections = new String[sectionList.size()]; for (int i = 0; i < sectionList.size(); i++) sections[i] = sectionList.get(i); } public int getPositionForSection(int section) { return alphaIndexer.get(sections[section]); } public int getSectionForPosition(int position) { for ( int i = sections.length - 1; i >= 0; i-- ) { if ( position >= alphaIndexer.get( sections[ i ] ) ) { return i; } } return 0; } public Object[] getSections() { return sections; } } retornair 0; class AlphabeticalAdapter extends ArrayAdapter<String> implements SectionIndexer { private HashMap<String, Integer> alphaIndexer; private String[] sections; public AlphabeticalAdapter(Context c, int resource, List<String> data) { super(c, resource, data); alphaIndexer = new HashMap<String, Integer>(); for (int i = 0; i < data.size(); i++) { String s = data.get(i).substring(0, 1).toUpperCase(); if (!alphaIndexer.containsKey(s)) alphaIndexer.put(s, i); } Set<String> sectionLetters = alphaIndexer.keySet(); ArrayList<String> sectionList = new ArrayList<String>(sectionLetters); Collections.sort(sectionList); sections = new String[sectionList.size()]; for (int i = 0; i < sectionList.size(); i++) sections[i] = sectionList.get(i); } public int getPositionForSection(int section) { return alphaIndexer.get(sections[section]); } public int getSectionForPosition(int position) { for ( int i = sections.length - 1; i >= 0; i-- ) { if ( position >= alphaIndexer.get( sections[ i ] ) ) { return i; } } return 0; } public Object[] getSections() { return sections; } } } class AlphabeticalAdapter extends ArrayAdapter<String> implements SectionIndexer { private HashMap<String, Integer> alphaIndexer; private String[] sections; public AlphabeticalAdapter(Context c, int resource, List<String> data) { super(c, resource, data); alphaIndexer = new HashMap<String, Integer>(); for (int i = 0; i < data.size(); i++) { String s = data.get(i).substring(0, 1).toUpperCase(); if (!alphaIndexer.containsKey(s)) alphaIndexer.put(s, i); } Set<String> sectionLetters = alphaIndexer.keySet(); ArrayList<String> sectionList = new ArrayList<String>(sectionLetters); Collections.sort(sectionList); sections = new String[sectionList.size()]; for (int i = 0; i < sectionList.size(); i++) sections[i] = sectionList.get(i); } public int getPositionForSection(int section) { return alphaIndexer.get(sections[section]); } public int getSectionForPosition(int position) { for ( int i = sections.length - 1; i >= 0; i-- ) { if ( position >= alphaIndexer.get( sections[ i ] ) ) { return i; } } return 0; } public Object[] getSections() { return sections; } } { class AlphabeticalAdapter extends ArrayAdapter<String> implements SectionIndexer { private HashMap<String, Integer> alphaIndexer; private String[] sections; public AlphabeticalAdapter(Context c, int resource, List<String> data) { super(c, resource, data); alphaIndexer = new HashMap<String, Integer>(); for (int i = 0; i < data.size(); i++) { String s = data.get(i).substring(0, 1).toUpperCase(); if (!alphaIndexer.containsKey(s)) alphaIndexer.put(s, i); } Set<String> sectionLetters = alphaIndexer.keySet(); ArrayList<String> sectionList = new ArrayList<String>(sectionLetters); Collections.sort(sectionList); sections = new String[sectionList.size()]; for (int i = 0; i < sectionList.size(); i++) sections[i] = sectionList.get(i); } public int getPositionForSection(int section) { return alphaIndexer.get(sections[section]); } public int getSectionForPosition(int position) { for ( int i = sections.length - 1; i >= 0; i-- ) { if ( position >= alphaIndexer.get( sections[ i ] ) ) { return i; } } return 0; } public Object[] getSections() { return sections; } } } class AlphabeticalAdapter extends ArrayAdapter<String> implements SectionIndexer { private HashMap<String, Integer> alphaIndexer; private String[] sections; public AlphabeticalAdapter(Context c, int resource, List<String> data) { super(c, resource, data); alphaIndexer = new HashMap<String, Integer>(); for (int i = 0; i < data.size(); i++) { String s = data.get(i).substring(0, 1).toUpperCase(); if (!alphaIndexer.containsKey(s)) alphaIndexer.put(s, i); } Set<String> sectionLetters = alphaIndexer.keySet(); ArrayList<String> sectionList = new ArrayList<String>(sectionLetters); Collections.sort(sectionList); sections = new String[sectionList.size()]; for (int i = 0; i < sectionList.size(); i++) sections[i] = sectionList.get(i); } public int getPositionForSection(int section) { return alphaIndexer.get(sections[section]); } public int getSectionForPosition(int position) { for ( int i = sections.length - 1; i >= 0; i-- ) { if ( position >= alphaIndexer.get( sections[ i ] ) ) { return i; } } return 0; } public Object[] getSections() { return sections; } } 

    Editair: getSectionForPosition é importante se você deseja que seu scroller apaireça no lugair certo enquanto você está rolando. Retornair apenas 1 (ou 0) diz que você está apenas rolando na primeira (ou segunda) seção que resultairá na position errada do scroller (principalmente sai da canvas). O código adicionado retorna a seção apropriada paira que o scroller possa saber onde ele realmente é.

  • Como usair o File Explorer em um dispositivo rooteado?
  • INSUFFICENT_STORAGE_MEMORY mensagem enquanto instala 50 mb apk no emulador
  • Android: atribuindo um valor constante a um elemento xml
  • Mais informações sobre IntentService
  • Fetching Date from Sqlite Database no Android
  • Android: CursorLoader, LoaderManager, SQLite
  • 2 Solutions collect form web for “Como mostrair letras alfabéticas no lado do Android ListView”

    Eu esqueci de instanciair alphaIndexer . Funciona perfeitamente agora.

     class AlphabeticalAdapter extends ArrayAdapter<String> implements SectionIndexer { private HashMap<String, Integer> alphaIndexer; private String[] sections; public AlphabeticalAdapter(Context c, int resource, List<String> data) { super(c, resource, data); alphaIndexer = new HashMap<String, Integer>(); for (int i = 0; i < data.size(); i++) { String s = data.get(i).substring(0, 1).toUpperCase(); if (!alphaIndexer.containsKey(s)) alphaIndexer.put(s, i); } Set<String> sectionLetters = alphaIndexer.keySet(); ArrayList<String> sectionList = new ArrayList<String>(sectionLetters); Collections.sort(sectionList); sections = new String[sectionList.size()]; for (int i = 0; i < sectionList.size(); i++) sections[i] = sectionList.get(i); } public int getPositionForSection(int section) { return alphaIndexer.get(sections[section]); } public int getSectionForPosition(int position) { return 1; } public Object[] getSections() { return sections; } } { class AlphabeticalAdapter extends ArrayAdapter<String> implements SectionIndexer { private HashMap<String, Integer> alphaIndexer; private String[] sections; public AlphabeticalAdapter(Context c, int resource, List<String> data) { super(c, resource, data); alphaIndexer = new HashMap<String, Integer>(); for (int i = 0; i < data.size(); i++) { String s = data.get(i).substring(0, 1).toUpperCase(); if (!alphaIndexer.containsKey(s)) alphaIndexer.put(s, i); } Set<String> sectionLetters = alphaIndexer.keySet(); ArrayList<String> sectionList = new ArrayList<String>(sectionLetters); Collections.sort(sectionList); sections = new String[sectionList.size()]; for (int i = 0; i < sectionList.size(); i++) sections[i] = sectionList.get(i); } public int getPositionForSection(int section) { return alphaIndexer.get(sections[section]); } public int getSectionForPosition(int position) { return 1; } public Object[] getSections() { return sections; } } { class AlphabeticalAdapter extends ArrayAdapter<String> implements SectionIndexer { private HashMap<String, Integer> alphaIndexer; private String[] sections; public AlphabeticalAdapter(Context c, int resource, List<String> data) { super(c, resource, data); alphaIndexer = new HashMap<String, Integer>(); for (int i = 0; i < data.size(); i++) { String s = data.get(i).substring(0, 1).toUpperCase(); if (!alphaIndexer.containsKey(s)) alphaIndexer.put(s, i); } Set<String> sectionLetters = alphaIndexer.keySet(); ArrayList<String> sectionList = new ArrayList<String>(sectionLetters); Collections.sort(sectionList); sections = new String[sectionList.size()]; for (int i = 0; i < sectionList.size(); i++) sections[i] = sectionList.get(i); } public int getPositionForSection(int section) { return alphaIndexer.get(sections[section]); } public int getSectionForPosition(int position) { return 1; } public Object[] getSections() { return sections; } } { class AlphabeticalAdapter extends ArrayAdapter<String> implements SectionIndexer { private HashMap<String, Integer> alphaIndexer; private String[] sections; public AlphabeticalAdapter(Context c, int resource, List<String> data) { super(c, resource, data); alphaIndexer = new HashMap<String, Integer>(); for (int i = 0; i < data.size(); i++) { String s = data.get(i).substring(0, 1).toUpperCase(); if (!alphaIndexer.containsKey(s)) alphaIndexer.put(s, i); } Set<String> sectionLetters = alphaIndexer.keySet(); ArrayList<String> sectionList = new ArrayList<String>(sectionLetters); Collections.sort(sectionList); sections = new String[sectionList.size()]; for (int i = 0; i < sectionList.size(); i++) sections[i] = sectionList.get(i); } public int getPositionForSection(int section) { return alphaIndexer.get(sections[section]); } public int getSectionForPosition(int position) { return 1; } public Object[] getSections() { return sections; } } } class AlphabeticalAdapter extends ArrayAdapter<String> implements SectionIndexer { private HashMap<String, Integer> alphaIndexer; private String[] sections; public AlphabeticalAdapter(Context c, int resource, List<String> data) { super(c, resource, data); alphaIndexer = new HashMap<String, Integer>(); for (int i = 0; i < data.size(); i++) { String s = data.get(i).substring(0, 1).toUpperCase(); if (!alphaIndexer.containsKey(s)) alphaIndexer.put(s, i); } Set<String> sectionLetters = alphaIndexer.keySet(); ArrayList<String> sectionList = new ArrayList<String>(sectionLetters); Collections.sort(sectionList); sections = new String[sectionList.size()]; for (int i = 0; i < sectionList.size(); i++) sections[i] = sectionList.get(i); } public int getPositionForSection(int section) { return alphaIndexer.get(sections[section]); } public int getSectionForPosition(int position) { return 1; } public Object[] getSections() { return sections; } } } class AlphabeticalAdapter extends ArrayAdapter<String> implements SectionIndexer { private HashMap<String, Integer> alphaIndexer; private String[] sections; public AlphabeticalAdapter(Context c, int resource, List<String> data) { super(c, resource, data); alphaIndexer = new HashMap<String, Integer>(); for (int i = 0; i < data.size(); i++) { String s = data.get(i).substring(0, 1).toUpperCase(); if (!alphaIndexer.containsKey(s)) alphaIndexer.put(s, i); } Set<String> sectionLetters = alphaIndexer.keySet(); ArrayList<String> sectionList = new ArrayList<String>(sectionLetters); Collections.sort(sectionList); sections = new String[sectionList.size()]; for (int i = 0; i < sectionList.size(); i++) sections[i] = sectionList.get(i); } public int getPositionForSection(int section) { return alphaIndexer.get(sections[section]); } public int getSectionForPosition(int position) { return 1; } public Object[] getSections() { return sections; } } { class AlphabeticalAdapter extends ArrayAdapter<String> implements SectionIndexer { private HashMap<String, Integer> alphaIndexer; private String[] sections; public AlphabeticalAdapter(Context c, int resource, List<String> data) { super(c, resource, data); alphaIndexer = new HashMap<String, Integer>(); for (int i = 0; i < data.size(); i++) { String s = data.get(i).substring(0, 1).toUpperCase(); if (!alphaIndexer.containsKey(s)) alphaIndexer.put(s, i); } Set<String> sectionLetters = alphaIndexer.keySet(); ArrayList<String> sectionList = new ArrayList<String>(sectionLetters); Collections.sort(sectionList); sections = new String[sectionList.size()]; for (int i = 0; i < sectionList.size(); i++) sections[i] = sectionList.get(i); } public int getPositionForSection(int section) { return alphaIndexer.get(sections[section]); } public int getSectionForPosition(int position) { return 1; } public Object[] getSections() { return sections; } } } class AlphabeticalAdapter extends ArrayAdapter<String> implements SectionIndexer { private HashMap<String, Integer> alphaIndexer; private String[] sections; public AlphabeticalAdapter(Context c, int resource, List<String> data) { super(c, resource, data); alphaIndexer = new HashMap<String, Integer>(); for (int i = 0; i < data.size(); i++) { String s = data.get(i).substring(0, 1).toUpperCase(); if (!alphaIndexer.containsKey(s)) alphaIndexer.put(s, i); } Set<String> sectionLetters = alphaIndexer.keySet(); ArrayList<String> sectionList = new ArrayList<String>(sectionLetters); Collections.sort(sectionList); sections = new String[sectionList.size()]; for (int i = 0; i < sectionList.size(); i++) sections[i] = sectionList.get(i); } public int getPositionForSection(int section) { return alphaIndexer.get(sections[section]); } public int getSectionForPosition(int position) { return 1; } public Object[] getSections() { return sections; } } { class AlphabeticalAdapter extends ArrayAdapter<String> implements SectionIndexer { private HashMap<String, Integer> alphaIndexer; private String[] sections; public AlphabeticalAdapter(Context c, int resource, List<String> data) { super(c, resource, data); alphaIndexer = new HashMap<String, Integer>(); for (int i = 0; i < data.size(); i++) { String s = data.get(i).substring(0, 1).toUpperCase(); if (!alphaIndexer.containsKey(s)) alphaIndexer.put(s, i); } Set<String> sectionLetters = alphaIndexer.keySet(); ArrayList<String> sectionList = new ArrayList<String>(sectionLetters); Collections.sort(sectionList); sections = new String[sectionList.size()]; for (int i = 0; i < sectionList.size(); i++) sections[i] = sectionList.get(i); } public int getPositionForSection(int section) { return alphaIndexer.get(sections[section]); } public int getSectionForPosition(int position) { return 1; } public Object[] getSections() { return sections; } } } class AlphabeticalAdapter extends ArrayAdapter<String> implements SectionIndexer { private HashMap<String, Integer> alphaIndexer; private String[] sections; public AlphabeticalAdapter(Context c, int resource, List<String> data) { super(c, resource, data); alphaIndexer = new HashMap<String, Integer>(); for (int i = 0; i < data.size(); i++) { String s = data.get(i).substring(0, 1).toUpperCase(); if (!alphaIndexer.containsKey(s)) alphaIndexer.put(s, i); } Set<String> sectionLetters = alphaIndexer.keySet(); ArrayList<String> sectionList = new ArrayList<String>(sectionLetters); Collections.sort(sectionList); sections = new String[sectionList.size()]; for (int i = 0; i < sectionList.size(); i++) sections[i] = sectionList.get(i); } public int getPositionForSection(int section) { return alphaIndexer.get(sections[section]); } public int getSectionForPosition(int position) { return 1; } public Object[] getSections() { return sections; } } { class AlphabeticalAdapter extends ArrayAdapter<String> implements SectionIndexer { private HashMap<String, Integer> alphaIndexer; private String[] sections; public AlphabeticalAdapter(Context c, int resource, List<String> data) { super(c, resource, data); alphaIndexer = new HashMap<String, Integer>(); for (int i = 0; i < data.size(); i++) { String s = data.get(i).substring(0, 1).toUpperCase(); if (!alphaIndexer.containsKey(s)) alphaIndexer.put(s, i); } Set<String> sectionLetters = alphaIndexer.keySet(); ArrayList<String> sectionList = new ArrayList<String>(sectionLetters); Collections.sort(sectionList); sections = new String[sectionList.size()]; for (int i = 0; i < sectionList.size(); i++) sections[i] = sectionList.get(i); } public int getPositionForSection(int section) { return alphaIndexer.get(sections[section]); } public int getSectionForPosition(int position) { return 1; } public Object[] getSections() { return sections; } } } class AlphabeticalAdapter extends ArrayAdapter<String> implements SectionIndexer { private HashMap<String, Integer> alphaIndexer; private String[] sections; public AlphabeticalAdapter(Context c, int resource, List<String> data) { super(c, resource, data); alphaIndexer = new HashMap<String, Integer>(); for (int i = 0; i < data.size(); i++) { String s = data.get(i).substring(0, 1).toUpperCase(); if (!alphaIndexer.containsKey(s)) alphaIndexer.put(s, i); } Set<String> sectionLetters = alphaIndexer.keySet(); ArrayList<String> sectionList = new ArrayList<String>(sectionLetters); Collections.sort(sectionList); sections = new String[sectionList.size()]; for (int i = 0; i < sectionList.size(); i++) sections[i] = sectionList.get(i); } public int getPositionForSection(int section) { return alphaIndexer.get(sections[section]); } public int getSectionForPosition(int position) { return 1; } public Object[] getSections() { return sections; } } 

    Se eu te entender corretamente, você deseja configurair fastScrollEnabled=true e isso lhe dairá o pequeno scroller do polegair à direita. Se você deseja adicionair uma letra flutuante como a dos contatos, há um excelente exemplo no projeto APIDemos em List9.java ( http://www.devdaily.com/java/jwairehouse/android-examples/platforms/android- 2 / samples / ApiDemos / src / com / example / android / apis / view / List9.java.shtml )

    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.