我正在开发一个应用程序,它需要处理几个位图,并将它们显示在一个网络视图中。如果用户单击按钮,则webview的内容可以更改。
一切正常,我拿了位图,在Base 64中转换它们,没问题。
然后,我决定稍微修改一下我的代码,使其更有条理,现在,webview只在第一次显示内容时,loadData()就什么也不做了,即使参数htmlString包含一个不同的HTML。我不明白为什么webview不再工作了。
没有来自No的错误警告,也没有例外,以及从UI线程运行loadData()
下面是一些代码:
// Load the pure html content, then calling loadData() with it
CompletableFuture.supplyAsync(htmlProvider::doHTML)
.thenAccept(htmlText ->
runOnUiThread(() -> {webView.loadData(htmlText, "text/html; charset=UTF-8", "UTF-8");
Logger.logV(htmlText);})) // Load data the first time, then do nothing even if html text has changed
.exceptionally(throwable -> {Logger.handleException(throwable); Logger.logV("ERROR"); return null;})
.thenRun(() -> {
Logger.logV("isLoading -> false");
isLoading = false;
});doHTML()只需提供一些html,并负责将位图作为Base64加载到其中。
谢谢你的帮忙
发布于 2020-02-04 09:41:27
这是loadData(String data, String mimeType, String encoding)方法中常见的问题,请用
loadDataWithBaseURL(String baseUrl,String data,String mimeType,String mimeType,String historyUrl)
https://stackoverflow.com/questions/60054291
复制相似问题