我正在尝试在互联网上下载一些图像并使用gridview将它们粘贴到屏幕中。但是当我使用BitmapDecoder选项时,图像不会出现。如果我不使用它(仅下载)图像出现在屏幕 :/
URL url = new URL(src);
Rect padding = new Rect(8,8,8,8);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setDoInput(true);
connection.connect();
InputStream input = connection.getInputStream();
final BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeStream(input, padding , options);
options.inSampleSize = calculateInSampleSize(options, 300, 300);
options.inJustDecodeBounds = false;
return BitmapFactory.decodeStream(input, padding, options);