我与这个问题斗争了很长时间,在谷歌和 SO 周围挖掘,但仍然没有运气。最后,我在这里得到您的帮助,请建议或帮助。
我对以下源代码的问题是它只显示图像不显示的字符串内容,而是显示白色矩形或有时带有问号的蓝色图像。
问:如何显示图像?
这是我的代码:
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();
}
}
网络视图输出: