比方说,我有一幅图片http://www.sina.com/mypicture.jpg
我在Android如何下载并显示此图片?

解决方案 »

  1.   

    用http Get, 有相关的接口
      

  2.   

    同意楼上的,至于如何显示那就是Android最基本的东西了
      

  3.   

    private Bitmap getRemoteImage(URL aURL) throws IOException{
       URLConnection conn = aURL.openConnection();
                conn.connect();
                InputStream is = conn.getInputStream();
                BufferedInputStream bis = new BufferedInputStream(is);
                Bitmap bm = BitmapFactory.decodeStream(bis);
                bis.close();
                is.close();            
       return bm;
      }3秒就完成. 接分
      

  4.   

    这样子也可以:public class LoadImage {
    private String log = "loadImage";
        HttpURLConnection uc ;
        URL url;
        InputStream is;
        BufferedInputStream bis;
        private static final String ip="code.google.com/android/images/logo_android.gif";
        private static final String host="";
        private static final String path = "http://" + ip +host ;
        public  LoadImage(){
         
                    openConn();
                    sendRequest();
                    getRespones();
                    closeConn();
          
        }    private void openConn(){
            try {
                url=new URL(path);
                uc = (HttpURLConnection)url.openConnection();
                uc.setDoInput(true);
            }catch (MalformedURLException e){
             Log.d(log,"exception openConn(1)");
                e.printStackTrace();
            } catch (IOException e) {
             Log.d(log,"exception openConn(2)");
                e.printStackTrace();
            }
        }    private void sendRequest(){
            try {
                uc.connect();
            } catch (IOException e) {
             Log.d(log,"exception sendRequest()");
                 e.printStackTrace();
            }
        }    private void getRespones(){
            try {
                is = uc.getInputStream();
                Log.d("lenght",""+uc.getContentLength());
                bis = new BufferedInputStream(is);
                Config.loadimage = BitmapFactory.decodeStream(bis);
            } catch (IOException e1) {
             Log.d(log,"exception getRespones()");
                e1.printStackTrace();
            }
        }    private void closeConn(){
            try {
                uc.disconnect();
                bis.close();
                is.close();
            } catch (IOException e) {
             Log.d(log,"exception closeConn()");
                e.printStackTrace();
            }
        }
    }