此代码(在我的CustomAdapter类中)仅显示基于谁向我发送文本消息的联系人 ID,并将它们放入 ArrayList,然后显示列表。
我holder.photo
在每个联系人 ID 旁边都调用了一个 ImageView。我将如何在 ImageView 中显示联系人的照片?
String folder = "content://sms/inbox/";
Uri mSmsQueryUri = Uri.parse(folder);
messages = new ArrayList<String>();
contactID = new ArrayList<String>();
SMS = new ArrayList<String>();
try {
c = context.getContentResolver().query(mSmsQueryUri,
new String[] { "_id", "address", "date", "body" },
null, null, null);
if (c == null) {
Log.i(TAG, "cursor is null. uri: " + mSmsQueryUri);
}
} catch (Exception e) {
//Log.e(TAG, e.getMessage());
} finally {
c.close();
}
c.moveToFirst();
while (c.moveToNext()) {
phoneNumber = c.getString(0);
contactID.add(phoneNumber);
}
holder.photo.?????
//contact will cycle through all names and display each in a listview.
holder.contact.setText(contactID.get(position);
目前,我的列表视图显示:
- android_icon-----John Doe
- android_icon-----简·史密斯
- android_icon-----富巴尔