加载从远程服务器映像? [英] Loading Images From Remote Server?

查看:108
本文介绍了加载从远程服务器映像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我的一些活动的若干图片,这些都是从远程服务器的所有连接。现在的问题是,每次我去的这些活动包含来自远程断绝图像之一。所有的图像必须首先加载,否则你会得到一个黑色的空白屏幕。有时需要约1-5分钟来加载,有时甚至强行关闭设备。反正我有可以解决这个问题?

I have several images on some of my Activities, and these are all connected from Remote Server. The problem is every time I go on one of these Activities that contain images from remote sever. All of the images must load first otherwise you will get a black empty screen. Sometimes it takes about 1-5 minutes to load, and sometimes it even force close the device. Is there anyway I can fix this issue?

下面是code我使用:

Here is the code I'm using:

ImageViewimgView =(ImageView)findViewById(R.id.image01);
        Drawable drawable = LoadImageFromWebOperations("http://forum.roda.hr/images/customavatars/avatar10164_2.gif");
        imgView.setBackgroundDrawable(drawable);



private Drawable LoadImageFromWebOperations(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;
        }
    }

我一直在挣扎了好几天试图弄清楚这一点,请大家帮我,那将是真正的意思是对我很重要。提前致谢!

I have been struggling for days trying to figure this out, please help me, it would be really mean a lot to me. Thanks in advance!

推荐答案

HTTP: //www.androidpeople.com/android-load-image-url-example

这应该帮助..

和作为JETT尝试与AsynTask做在怠尽装载在后台。

and as jett try doing it in lazy with AsynTask to do the loading in background..

这篇关于加载从远程服务器映像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆