我有以下代码:
m_curContacts = managedQuery(uri, projection, selection, selectionArgs,
sortOrder);
String[] fields = new String[] { ContactsContract.Data.DISPLAY_NAME };
m_slvAdapter = new SimpleCursorAdapter(this,
R.layout.list, m_curContacts, fields,
new int[] { R.id.textview });
布局R.layout.list有2个元素:textview和imageview。我想问一下如何在m_slvAdapter中添加imageview?
如何添加以下内容:
Uri[] photo = new Uri[] {
Uri.withAppendedPath(ContentUris.withAppendedId
(ContactsContract.Contacts.CONTENT_URI,getContentResolver().query
(ContactsContract.Contacts.CONTENT_URI,null,
ContactsContract.Contacts.IN_VISIBLE_GROUP + " = '1'", null,
ContactsContract.Contacts.DISPLAY_NAME+" COLLATE LOCALIZED ASC")
.getLong(getContentResolver()
.query(ContactsContract.Contacts.CONTENT_URI,null,
ContactsContract.Contacts.IN_VISIBLE_GROUP + " = '1'", null,
ContactsContract.Contacts.DISPLAY_NAME+" COLLATE LOCALIZED ASC")
.getColumnIndex(ContactsContract.Contacts._ID))),
ContactsContract.Contacts.Photo.CONTENT_DIRECTORY)
};
我想添加近场和
new int[]{R.id.contact}
照片和
new Uri[] {
contactimage.setImageResource(R.drawable.image);
}
或类似的东西。
答案 0 :(得分:0)
您需要创建自己的ViewBinder。尝试查看回答同一问题的主题:
SimpleCursorAdapter with ImageView and TextView