我在獲取圖像格式Internet時遇到問題。 我有自定義佈局圖像視圖和文本視圖的列表視圖。 在我的情況下,我正在使用給定的打擊功能獲取圖像形式的互聯網,但是當大圖像來發生位圖大小異常。當獲取圖像格式Internet時,會發生位圖大小超過異常
private static InputStream fetch(String urlString)
throws MalformedURLException, IOException {
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpGet request = new HttpGet(urlString);
HttpResponse response = httpClient.execute(request);
return response.getEntity().getContent();
}
Resources res;
// *********** Function For Fetching Image form Internet
public static Drawable LoadImage(String URL, BitmapFactory.Options options) {
try {
if (fetch(URL) != null) {
try {
InputStream obj = fetch(URL);
bmp = BitmapFactory.decodeStream(obj, null, options);
obj.reset();
} catch (Exception e) {
}
Drawable drawable = new BitmapDrawable(bmp);
return drawable;
} else {
bitmap = BitmapFactory.decodeResource(
TennisAppActivity.mContext.getResources(),
R.drawable.profileplaceholder);
Drawable drawable = new BitmapDrawable(bitmap);
return drawable;
}
} catch (Exception e) {
Log.e("GUIMethodClasas", "fetchDrawable failed", e);
return null;
}
}
我使用上述代碼從互聯網獲取圖像。 請任何朋友儘快給我一個解決方案。
請定義一個「大圖」。尺寸?尺寸?堆棧跟蹤? – WarrenFaith 2011-04-05 12:08:27
這適用於我假設的一些圖像,但只與大圖像崩潰?我有一些類似的代碼與圖像大小調整,以防止類似的錯誤,當我從工作中,我會張貼從畫廊選擇大型圖像。 – DeliveryNinja 2011-04-05 12:14:56