1

Hi I am using a customized android listview with custom arrayadapter from a tutorial on this website for my application.

http://www.ezzylearning.com/tutorial.aspx?tid=1763429

In the MainActivity.java they have:

Weather weather_data[] = new Weather[]
    {
        new Weather(R.drawable.weather_cloudy, "Cloudy"),
        new Weather(R.drawable.weather_showers, "Showers"),
        new Weather(R.drawable.weather_snow, "Snow"),
        new Weather(R.drawable.weather_storm, "Storm"),
        new Weather(R.drawable.weather_sunny, "Sunny")
    };

What I want to do is retrieve images from the web such as http://spe.atdmt.com/ds/NMMRTSMGUWDS/121114_reddit/Win8_wiki_728x90_v2.jpg

and use it instead of R.drawable.*

I have tried converting a URL link to a Bitmap image then changing a couple lines of code in

Weather.java:

from public int icon; to public Bitmap icon;

and

from public Weather(int icon, String title) to public Weather(Bitmap icon, String title)

WeatherAdapter.java:

from holder.imgIcon.setImageResource(weather.icon); to holder.imgIcon.setImageBitmap(weather.icon);

I must not totally understand the code. I hope someone can help me out here. Thank you

Omar Reyes
  • 21
  • 2

1 Answers1

0

Well, you'll have to start by actually downloading the images (using this implementation, for example). Once you asynchronously download the images to some temporary directory, you can use BitmapFactory to open those files and get the Bitmap objects that you need.

You should also look into lazy loading the images into your ListView.

Community
  • 1
  • 1
Oleg Vaskevich
  • 12,444
  • 6
  • 63
  • 80