views:

53

answers:

1

I am building a android aplication which will be consuming a json file from the internet. This json file contains a list of news from a particular website. Each json object contains information such like title, summary, descripition and web links for the news thumbnail and the original image.

I will be displaying in a listview three information: the news thumbnail, the title and the summary. Here resides my problem. I dont want to load all thumbnails from the internet if they wont be displayed. What I am trying to say is that why download a thumbnail from the 30th news if the user wont scroll down the image. So, i will, initially only download the thumnails from those news that are being displayed in the screen and when the user scrolls down to see more news, as soon as the list item appers to the screen i want to download the image and then display.

Is there a way to achieve this? Is it possible to find out if the list item is on the screen? I have been searching all over the internet for a solution for this but i am running out of ideas.

Thanks T

A: 

You essentially want to lazy load your images. This will only load images that are currently being shown and as you scroll through the list view it will go and fetch those currently shown images.

Bryan Denny
Great example, but i have no idea how to use the code provided on the answer 38, which I think is the best choice. Do i need to use it inside my base adapter?
Thiago