如何在不下载的情况下加载 android 中的一张图片

How to load one image in android WITH OUT download

认识你们中的任何人,我怎样才能在不下载的情况下使用 URL 中的一张照片?因为我可以有很多图像,如果我的应用程序无法下载所有图像...... 我在网上找到了一个功能,他怎么能做到这一点,但它不起作用。

public static Drawable LoadImageFromWebOperations(String url) {
        try {
            InputStream is = (InputStream) new URL(url).getContent();
            Drawable d = Drawable.createFromStream(is, "src name");
            return d;
        } catch (Exception e) {
            return null;
        }
    }

我真的很需要它,有人知道吗?

您可以使用 Picasso 库从 url 下载图像:

http://square.github.io/picasso/

示例:

Picasso.with(context).load("http://i.imgur.com/DvpvklR.png").into(imageView);