阅读更多
String url = "http://192.168.1.114:9000/data/attachments/342ac65c103853433bec12409113b07eca8088b4.jpg";imgIV = (ImageView) findViewById(R.id.home_news_img_iv);bitmap= Tools.getBitMap(url);imgIV.setImageBitmap(bitmap);


package com.newsapp.util;import java.io.IOException;import java.io.InputStream;import java.net.HttpURLConnection;import java.net.MalformedURLException;import java.net.URL;import android.graphics.Bitmap;import android.graphics.BitmapFactory;public class Tools {public static Bitmap getBitMap(String url){        URL myFileUrl = null;           Bitmap bitmap = null;          try {               myFileUrl = new URL(url);           } catch (MalformedURLException e) {               e.printStackTrace();           }           try {               HttpURLConnection conn = (HttpURLConnection) myFileUrl                 .openConnection();               conn.setDoInput(true);               conn.connect();               InputStream is = conn.getInputStream();               bitmap = BitmapFactory.decodeStream(is);               is.close();           } catch (IOException e) {                 e.printStackTrace();           }                 return bitmap;       }  }

更多相关文章

  1. Android(安卓)TextView显示html图片
  2. Speed Up and Back Up Your Rooted Android(安卓)Phone
  3. android 監聽系統屬性變化的方法
  4. andorid RecyclerView下拉刷新,上拉加载更多
  5. android 客户端 smtp 协议发送数据
  6. android 连接CMWAP
  7. Android再按一次退出程序实现方法
  8. android 客户端 smtp 协议发送数据
  9. Android(安卓)打开pdf文档,没有阅读器链接到Google Play Store等

随机推荐

  1. 再也没有比这更快的JS模板引擎:TiniestTpl
  2. 终于有人把网络爬虫讲明白了
  3. 主辅及智能DNS实现与MySQL5.7.32编译安装
  4. Amazon Alexa和Google Home语言系统的前
  5. 详解4种类型的爬虫技术
  6. Vivado一项全新项目功能——可配置的报告
  7. Python高能小技巧:了解bytes与str的区别
  8. NSGA-II多目标优化算法讲解(附MATLAB代码)
  9. CW节约算法构造VRPTW初始解(附MATLAB代码)
  10. 数字化转型最致命的5个误区