2012-08-02 72 views
0

我有以下代碼:機器人簡單光標適配器imageview的和的TextView

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

或類似的東西。

回答