0
我很長一段時間都在與這個問題作鬥爭,在Google和SO周圍挖掘,但仍然沒有運氣。最後,我在這裏得到你的幫助,請提供建議或幫助。loadDataWithBaseURL不會加載屬於html頁面的圖像
我與以下源代碼的問題是它只顯示字符串內容的圖像不顯示相反,它顯示白色矩形或有時帶問號的藍色圖像。
問:如何顯示圖像?
這裏是我的代碼:
private void openURL() {
DefaultHttpClient client = new HttpsRequest(getApplicationContext());
HttpGet get = new HttpGet(getUrlField().getText().toString());
// Execute the GET call and obtain the response
HttpResponse getResponse;
try {
getResponse = client.execute(get);
HttpEntity responseEntity = getResponse.getEntity();
String content = EntityUtils.toString(responseEntity);
getWebView().loadDataWithBaseURL(null, content, "text/html", "utf-8",
null);
} catch (ClientProtocolException e) {
WSLog.e(THIS_FILE, "HTTP Error.");
e.printStackTrace();
} catch (IOException e) {
WSLog.e(THIS_FILE, "Url Load Error.");
e.printStackTrace();
}
}
webView的輸出:
代替loadDataWithBaseURL中的第一個'null',您必須在其中放置getUrlField()。getText ).toString()' – vasart
感謝您的回覆,但並未解決問題。我仍然看到相同的輸出。感謝您的建議。 – mask
你知道存儲這個頁面的圖像的URL嗎?你必須把這個url作爲loadDataWithBaseURL中的第一個參數 – vasart