2012-06-13 3 views
1

이 코드 (내 CustomAdapter 클래스 내)는 문자 메시지를 보낸 사람을 기반으로 연락처 ID 만 표시하고이를 ArrayList에 넣은 다음 목록을 표시합니다.연락처의 ID로 연락처 사진을 어떻게 표시합니까?

각 연락처 ID 옆에 holder.photo이라는 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 ----- 홍길동
  • android_icon ----- 제인 스미스
  • android_icon ----- 푸 바

답변

3

이 시도 ..

01 23,

public static Bitmap loadContactPhoto(ContentResolver cr, long id) { 
    Uri uri = ContentUris.withAppendedId(
      ContactsContract.Contacts.CONTENT_URI, id); 
    InputStream input = ContactsContract.Contacts 
      .openContactPhotoInputStream(cr, uri); 
    if (input == null) { 
     return null; 
    } 
    return BitmapFactory.decodeStream(input); 
} 
+0

가 감사합니다 나를 위해 작동 비트 맵 이미지를 얻을 –

관련 문제