Able
Able

Reputation: 47

(Beginner) How do I automatically load images off of a website into an imageview

I'm building an app for a friends funny pictures website. I downloaded the gridview activity from the android developers website, but it just loads preset image urls, and that's simply not going to work for us. We need an image loader that can automatically load images from the site.

Any help would be greatly appreciated.

Upvotes: 0

Views: 211

Answers (4)

laaptu
laaptu

Reputation: 2973

Hope AQuery library is what you are looking for easy image loading on ImageView

Upvotes: 1

Kgrover
Kgrover

Reputation: 2116

Rather than what others are suggesting, I think the best way to do this is use a UniversalImageLoader. It will allow you to Lazy Load, and cache on the SD card and internal storage. In short, it makes things simpler and allows you to get the fastest speed possible. Try it out.

Upvotes: 0

Murtuza Kabul
Murtuza Kabul

Reputation: 6514

Try out this

Drawable drawable = LoadImage(<Replace this with your url> + UserProfile.Photo);
UserPhotoImageView.setImageDrawable(drawable);
<replace with Your Image View>.setImageDrawable(drawable);


public Drawable LoadImage(String url)
    {
        try
        {
            InputStream is = (InputStream) new URL(url).getContent();
            Drawable d = Drawable.createFromStream(is, "src name");
            return d;
        }
        catch (Exception e)
        {
            System.out.println("Exc=" + e);
            return null;
        }
    }

Upvotes: 0

Related Questions