android转换网络图片显示
来源:互联网 发布:java中的回调函数 编辑:程序博客网 时间:2024/06/06 02:00
/**
* convert server image to bitmap
*
* @param url
* @return
*/
public static Bitmap ConvertBitMap(String url) {
URL myFileUrl = null;
Bitmap bitmap = null;
InputStream inputStream = null;
try {
myFileUrl = new URL(url);
HttpURLConnection conn = (HttpURLConnection) myFileUrl.openConnection();
conn.setDoInput(true);
conn.connect();
inputStream = conn.getInputStream();
bitmap = BitmapFactory.decodeStream(inputStream);
}
catch (MalformedURLException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}finally
{
if (null != inputStream)
{
try
{
inputStream.close();
}
catch (IOException e)
{
e.printStackTrace();
}
}
}
return bitmap;
* convert server image to bitmap
*
* @param url
* @return
*/
public static Bitmap ConvertBitMap(String url) {
URL myFileUrl = null;
Bitmap bitmap = null;
InputStream inputStream = null;
try {
myFileUrl = new URL(url);
HttpURLConnection conn = (HttpURLConnection) myFileUrl.openConnection();
conn.setDoInput(true);
conn.connect();
inputStream = conn.getInputStream();
bitmap = BitmapFactory.decodeStream(inputStream);
}
catch (MalformedURLException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}finally
{
if (null != inputStream)
{
try
{
inputStream.close();
}
catch (IOException e)
{
e.printStackTrace();
}
}
}
return bitmap;
}
引用:
- imView = (ImageView) findViewById(R.id.imageView);
- imView.setImageBitmap(ConvertBitMap(imageUrl));
- android转换网络图片显示
- Android 网络图片显示
- Android显示网络图片
- android 网络图片显示
- android中显示网络图片
- Android:如何显示网络图片
- android ListView显示网络图片
- android中显示网络图片
- Android中显示网络图片
- Android中显示网络图片
- android ListView显示网络图片
- Android中显示网络图片
- Android中显示网络图片
- Android显示网络图片(笔记)
- Android显示网络中的图片
- Android TextView显示网络图片
- 如何在Android当中显示网络图片
- 如何在Android当中显示网络图片
- 汉字文章转换拼音的好工具 pinyinConvert.v20120709
- 1、框架
- 2、顶点缓冲
- 3、索引缓冲
- 4、纹理
- android转换网络图片显示
- 一点随想
- 5、动画和矩阵变换
- 6、光照和材质
- 7、多重纹理和纹理混合
- 8、DXUT框架
- 浅谈MySQL存储引擎选择 InnoDB还是MyISAM
- DXUT 设计指南
- JAVA操作符位移详解