I need to display the contact pictures in a list view. In my custom_row_view.xml I have:
<ImageView
android:id="@+id/contact_image"
android:layout_width="60dp"
android:layout_height="50dp"
/>
and then in my activity i have:
final SimpleAdapter adapter = new SimpleAdapter(
this,
list,
R.layout.custom_row_view,
new String[] {"avatar","telnumber","date","name","message","sent"},
new int[] {R.id.contact_image,R.id.text1,R.id.text2,R.id.text3,R.id.text4,R.id.isent}
);
I have a hashmap HashMap temp2 = new HashMap(); where i put all the values of each line. ("list" is a list of Hashmap)
But when I do:
Cursor photo2 = managedQuery(
Data.CONTENT_URI,
new String[] {Photo.PHOTO}, // column for the blob
Data._ID + "=?", // select row by id
new String[]{photoid}, // filter by photoId
null);
Bitmap photoBitmap = null;
if(photo2.moveToFirst()) {
byte[] photoBlob = photo2.getBlob(photo2.getColumnIndex(Photo.PHOTO));
photoBitmap = BitmapFactory.decodeByteArray(photoBlob, 0, photoBlob.length);
if (photoBitmap != null)
temp2.put("avatar",photoBitmap);
else
temp2.put("avatar",R.drawable.unknowncontact);
}
photo2.close();
Nothing is displayed! "temp2.put("avatar",photoBitmap);" does not display anything but when I try to display something from the drawable folder it works!!!
Please help me, i have been locked on this problem for several days!
Thanks a lot!