Posts

Showing posts from August, 2015
How to Add Section Indexers in a Android List View Crete the Adapter for list view . public class ContactsAdapter extends BaseAdapter implements SectionIndexer { Context context; String[] strings; String[] sections ; HashMap alphaIndexer; public ContactsAdapter(Context context, String[] strings) { this.context = context; this.strings = strings; alphaIndexer = new HashMap (); int size = strings.length; for (int x = 0; x < size; x++) { String s = strings[x]; String ch = s.substring(0, 1); ch = ch.toUpperCase(); if (!alphaIndexer.containsKey(ch)) alphaIndexer.put(ch, x); } Set sectionLetters = alphaIndexer.keySet(); ArrayList sectionList = new ArrayList<>(sectionLetters); Collections.sort(sectionList); sections = new String[sectionList.size()]; sectionList.toArray(sections); } @Overr