Last active
August 29, 2015 13:57
-
-
Save pwittchen/9400162 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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