Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@pwittchen
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pwittchen/9400162 to your computer and use it in GitHub Desktop.
Save pwittchen/9400162 to your computer and use it in GitHub Desktop.
@Override
protected void onResume() {
List<Contact> contacts = getContactsFromYourSource();
ContactsAdapter contactsAdapter = new ContactsAdapter(contacts);
contactListView.setAdapter(contactsAdapter);
highlightListItem(2); // this simple function call does the trick
}
private void highlightListItem(int position) {
ContactsAdapter contactsAdapter = (ContactsAdapter) contactListView.getAdapter();
contactsAdapter.setSelectedItem(position);
// in some cases, it may be necessary to re-set adapter (as in the line below)
contactListView.setAdapter(contactsAdapter);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment