我有以下内容
String urlStr = "http://example.com/my.jpg"
String mimeType = "image/jpeg";
String encoding = null;
String pageData = ""; // This is data read in from an HttpURLConnection
webview.loadDataWithBaseURL(urlStr, pageData, mimeType, encoding, urlStr);
Run Code Online (Sandbox Code Playgroud)
但是当我运行它时,我看到的只是一个蓝色问号而不是我的图像.使用loadData处理在WebView中显示图像的正确方法是什么?
编辑:
有没有办法在不传递pageData的情况下执行此操作<img src="http://example.com/my.jpg/">?如果loadData只能处理"text/html",那么loadData采用mime类型似乎很愚蠢.特别是因为javadoc列出了"image/jpeg"作为你可能传入的mime类型的例子.
android ×1