views:

42

answers:

1

I have found this example http://stackoverflow.com/questions/541966/android-how-do-i-do-a-lazy-load-of-images-in-listview/3068012#3068012 from Fedor which is absolutely great for what I need.

I have a question. if beside the Clear Cache button there would be a TextView how could I put in there how many images from total images had downloaded ? If I know that I will download a total of 20 images, the status as one image after another will download would be 1/20. 2/20... 20/20.

+1  A: 

You would need a variable that contains the number of downloaded images, and each time an image is downloaded you update the variable, and then set that as text on the text view.

You want to be looking at this code inside ImageLoader.java

if(((String)photoToLoad.imageView.getTag()).equals(photoToLoad.url)){ BitmapDisplayer bd=new BitmapDisplayer(bmp, photoToLoad.imageView); Activity a=(Activity)photoToLoad.imageView.getContext(); a.runOnUiThread(bd); }

Which is executed each time an image is downloaded. In there you could update the variable that you have added and call a method on the ui thread to update the text view.

monkjack
I am now studying the code. I don't understand every bit of it, so what you've explained seems very Ok, but right now I don't know how could I implement it. I really don't know how to get a reference to the TextView. Thank you for your time.
Alin
I followed your advise. I took a reference for the TextView from Activity a, and send it to BitmapDisplayer, with the new variable. In there I can set the text with whatever I want. Thank you for your suggestion.
Alin