Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
@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
You can’t perform that action at this time.