0

I have successfully implemented sectioned listview, but now I'm facing a problem i.e. each row in ListView has some Textview plus ImageView.
The image in ImageView is only displayed when I use R.drawalbe.myimage i.e. when I assign an integer id.
But it doesn't work when I actually assign an Bitmap or Drawable. Basically these bitmaps are downloaded from internet, how can I make then appear in sectioned ListView.

     // this works
      security.add(createItem(v1, v2, v3, v4, v6, R.drawable.add));                 

     // this doesnt work
     Bitmap b; // loaded from somewhere
      security.add(createItem(v1, v2, v3, v4, v6, b));

   public Map<String, ?> createItem(String title, String caption, String date, String hrs, String lnk, int obj)
{
    Map<String, Object> item = new HashMap<String, Object>();
    item.put(ITEM_TITLE, title);
    item.put(ITEM_CAPTION, caption);
    item.put(ITEM_DATE, date);
    item.put(VISIBLE_DATE, hrs);
    item.put(LINK, lnk);
    item.put(IMAGE, obj);

    return item;
}
GAMA
  • 5,958
  • 14
  • 79
  • 126
Programmer
  • 5,360
  • 10
  • 37
  • 61
  • You can use this to load images in ListView directly: [Android - How do I do a lazy load of images in ListView](http://stackoverflow.com/questions/541966/android-how-do-i-do-a-lazy-load-of-images-in-listview) – Paresh Mayani Jun 18 '12 at 05:36
  • so you just need to put WebURL of image(instead of bitmap object) in the Hashmap. – Paresh Mayani Jun 18 '12 at 05:36
  • Sorry bro..its not working, can u plz suggest me some other method. Even when i downloaded images and passed to it, it didnt work. – Programmer Jun 18 '12 at 05:49
  • 1
    no need to pass downloaded images, just a URL can work. – Paresh Mayani Jun 18 '12 at 05:50
  • i am passing bitmap, but now i got this error 06-18 11:34:56.779: I/System.out(1167): resolveUri failed on bad bitmap uri: android.graphics.Bitmap@406892f8. Can you plz tell me why uri is showing this error. – Programmer Jun 18 '12 at 06:06
  • i beleive your solution did worked for me, but still i am getting this error 06-18 11:56:27.159: I/System.out(513): resolveUri failed on bad bitmap uri: android.graphics.Bitmap@405e06f0 – Programmer Jun 18 '12 at 06:28

1 Answers1

1

Use this String.valueOf rather then what you are using it now, it would always fail if you use the current code.

IMCoder
  • 231
  • 3
  • 5