KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I've looked at a lot of tutorials for making a ListView have the alphabetical letters on the side (like the Contacts list), but they all seem to using a ListActivity class and/or data from a database while I'm just using a ListView (no special Activity) and an ArrayList of data. Does anyone know how I can implement that alphabetical-scroll feature in the Contacts list for my own ListView? Edited Again I followed this tutorial , which I thought would finally make it work, but I'm still getting a forced close. 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; } } In the LogCat, it says java.lang.RuntimeException: Unable to resume activity {(package of another app I made) android.app.SuperNotCalledExcpetion . I thought that was really weird because I don't ref
Tags (comma-separated)
Save Edits
Cancel