I am showing all contacts in listview and it is working great. But I also want to add image to listview. Searched alot but didn't find any good tutorial. Please suggest some tutorials for showing contact images on listview. Following is my code.
Cursor cur = getContacts();
ListView lv = getListView();
String[] fields = new String[] {ContactsContract.Data.DISPLAY_NAME };
adapter = new SimpleCursorAdapter(this,
R.layout.contacts_list_row, cur, fields,
new int[] { R.id.title}, 0);
lv.setAdapter(adapter);
getContacts()
private Cursor getContacts() {
// Run query
Uri uri = ContactsContract.Contacts.CONTENT_URI;
String[] projection = new String[] { ContactsContract.Contacts._ID,
ContactsContract.Contacts.DISPLAY_NAME };
String selection = null;
String[] selectionArgs = null;
String sortOrder = ContactsContract.Contacts.DISPLAY_NAME
+ " COLLATE LOCALIZED ASC";
return managedQuery(uri, projection, selection, selectionArgs,
sortOrder);
}
Thanks in advance :)
See Question&Answers more detail:os