android 网络图片下载注意事项
2010-05-11 16:10:00 来源:WEB开发网核心提示:if (length != -1) {byte[] imgData = new byte[length];byte[] temp = new byte[512];int readLen = 0;int destPos = 0;while ((readLen = is.read(temp)) > 0) {Syste
if (length != -1) {
byte[] imgData = new byte[length];
byte[] temp = new byte[512];
int readLen = 0;
int destPos = 0;
while ((readLen = is.read(temp)) > 0) {
System.arraycopy(temp, 0, imgData, destPos, readLen);
destPos += readLen;
}
bitmap = BitmapFactory.decodeByteArray(imgData, 0,
imgData.length);
}
} catch (IOException e) {
bitmap = BitmapFactory.decodeResource(c.getResources(),
com.jixuzou.moko.R.drawable.defaultimg);
return bitmap;
}
return bitmap;
}
更多精彩
赞助商链接