Skip to content

Instantly share code, notes, and snippets.

@quanturium
Last active December 17, 2015 01:39
Show Gist options
  • Save quanturium/5529734 to your computer and use it in GitHub Desktop.
Save quanturium/5529734 to your computer and use it in GitHub Desktop.
@Override 
protected TreeMap<Integer, Object> initializeSections(Cursor c) 
{
TreeMap<Integer, Object> sections = new TreeMap<Integer, Object>();
int offset = 0, i = 0;
while (c.moveToNext())
{
String firstname = c.getString(c.getColumnIndex(CursorSectionDirectoryDatabase.COL_FIRSTNAME));
String firstLetter = firstname.substring(0, 1);
if (!sections.containsValue(firstLetter))
{
sections.put(offset+i, firstLetter);
offset++;
}
i++;
}
return sections;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment