0

我有以下代码:

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);
}

或类似的东西。

4

1 回答 1

0

您需要创建自己的 ViewBinder。尝试查看已回答相同问题的主题:
SimpleCursorAdapter with ImageView and TextView

于 2012-08-02T23:54:04.090 回答