我正在尝试像这样使用 WebView:
String html = " <html><body>
<table style\"background-color: #0a82a4; color: #ffffff;\">
... stuff ...
</table>"
</body>
</head>";
html.replace("#", "%23");
html.replace("\\", "%27");
html.replace("?", "%3f");
html.replace("%", "%25");
myWebview.loadData(html, "text/html", "utf-8");
它可以工作,但是当在样式标签中添加 width=100% 时,webView 无法加载数据。
哈哈,解决了:
html = html.replace("%", "%25");
html = html.replace("#", "%23");
html = html.replace("\\", "%27");
html = html.replace("?", "%3f");
最佳答案
您是否看过位于 here 的开发指南中的 HelloWorld 示例?
关于Android,将 WebView 与 loadData 一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7125976/