user264953
user264953

Reputation: 1967

Adding image to listview rows

Following is the snippet I use to add images to each row in a listview:

while (adapterDeal.getNextImageLink() != null) {
            System.out.println("Inside while loop for images");
            try {
                url = new URL(adapterDeal.getNextImageLink());
                stream = (InputStream) url.getContent();
                drawable = Drawable.createFromStream(stream, "src");
                adapterDeal.setImage(drawable);
                handler.sendEmptyMessage(IMAGE_DOWNLOADED);
            } catch (MalformedURLException e) {
                System.out.println("Inside MalformedURLException"+e);
                packAndSendMessage(e);
            } catch (IOException e) {
                System.out.println("Inside IOException"+e);
                packAndSendMessage(e);
            }
            break;
        }

Inside handler, I do notifydatasetchanged to get the listview row updated with image.

The problem I have is, it gets inside the while loop only once, though I have, say 'n' number of rows in the listview and each row has an image url, as well.

After getting inside the while loop for the first time, in DDMS, it shows :

01-26 23:32:27.104: I/System.out(1628): Inside while loop for images
01-26 23:32:28.434: D/dalvikvm(1628): GC_FOR_ALLOC freed 45K, 8% free 5901K/6407K, paused 120ms
01-26 23:32:28.453: I/dalvikvm-heap(1628): Grow heap (frag case) to 6.467MB for  640016-byte allocation
01-26 23:32:28.714: D/dalvikvm(1628): GC_CONCURRENT freed 1K, 8% free 6525K/7047K, paused 16ms+12ms

What can be the reason, it gets inside the while loop only once. Is it memory related?

Any help is appreciated.

Upvotes: 0

Views: 124

Answers (1)

Ryan
Ryan

Reputation: 2260

Because you have a break at the bottom of the loop ;-)

Upvotes: 2

Related Questions