I'm able to retrieve contact name and phone, but how to retrieve contact photo in one query?
String[] PROJECTION = new String[] { Contacts.People._ID, Contacts.PeopleColumns.NAME, Contacts.Phones.NUMBER };
Cursor c = a.managedQuery(Contacts.People.CONTENT_URI, PROJECTION, null, null, Contacts.People.DEFAULT_SORT_ORDER);
return (new SimpleCursorAdapter(a,
R.layout.list_row,
c,
new String[] { Contacts.PeopleColumns.NAME, Contacts.Phones.NUMBER },
new int[] { R.id.toptext, R.id.b开发者_如何学JAVAottomtext }));
I'm in the same boat (and for android-3 through android-5 to boot)!
I don't see a column for a photo in either 1.x or 2.x, so I'm just about resigned to using a CursorAdapter with a makeshift View Holder (private class, assigned to the anon view tag) for good measure, then using loadContactPhoto in bindView as needed.
The trick there would appear to be avoiding undue/excess scaling (e.g., cache the results of Bitmap.createScaledBitmap for each photo, at the very least?), lest the view slows down again and you lose the benefits of having a cursor-driven list in the first place.
I know, getting messy. I'm sure there's got to be a better way! Well, I'm hopeful there is. :)
精彩评论