且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何从URL中的机器人获得的图像

更新时间:2023-11-19 08:05:37

您可以直接显示来自Web图像而无需下载。请检查下面的功能。它会显示来自网络的图片到你的图像视图。

You can directly show image from web without downloading it. Please check the below function . It will show the images from the web into your image view.

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;
    }
}

然后设置图像的ImageView使用您的活动code。

then set image to imageview using code in your activity.