【发布时间】:2018-04-08 16:51:12
【问题描述】:
我正在尝试将 HTML 内容加载到 android Webview 中。我创建了一个下拉菜单,您可以在其中选择任何 HTML 内容,并且选择的 HTML 内容应加载到下面的 Web 视图中。但是数据加载不是很一致。 HTML 在桌面浏览器中正确呈现。 When a particular HTML content is selected Webview will display empty content and when tapped for 3-4 times data will load. When the HTML content is selected to load the previously selected content will also be present in the background.任何帮助将非常感激。使用下面提到的代码。
WebView mWebViewContent = new WebView(getContext());
mWebViewContent.getSettings().setJavaScriptEnabled(true);
mWebViewContent.setWebChromeClient(new WebChromeClient());
ViewGroup.LayoutParams params = mRelativeWebViewContent.getLayoutParams();
mWebViewContent.clearHistory();
mWebViewContent.clearFormData();
mWebViewContent.clearCache(true);
mWebViewContent.loadDataWithBaseURL(null, replaceHTML, "text/html", "UTF-8", null);
// mWebViewContent.loadData(replaceHTML,"text/html","UTF-8");
mRelativeWebViewContent.setLayoutParams(params);
mRelativeWebViewContent.addView(mWebViewContent);
目前我正在以编程方式创建 Webview 并将其添加到相对布局中。添加使用 XML 时,我也遇到了同样的问题。
【问题讨论】:
标签: android android-layout webview android-webview