我正在开发一个简单的 Android 应用程序来为一周中的每一天显示不同的页面。
我有一个 HTML 文件,我用 Microsoft Word 将其另存为过滤后的网页。
它在 API 17 的 WebView 中呈现正常。
它在 API 8 的浏览器中呈现正常。
但是,在 API 8 的 WebView 中,它被报告为“网页不可用”,然后显然它在
之后列出了回复文本"The Web page at " blah "might be temporarily down,
or..(more misdirection to useless impossibilities)"
blah 看起来像是我希望它呈现的 HTML 的正确字符(根本不是 URL)!我希望我可以粘贴它……好吧,如果我在调试器中停止,也许我可以……
HTML 包含我认为重要的评论。如果我手动编辑掉该评论,那么它在 API 8 WebView 中呈现正常!
这条评论有什么魔力吗?还是违反了一些微软不知道的评论规则?
如果您看到并解决了类似的问题,我将不胜感激。
我将粘贴失败的 HTML:
<html>
<head>
<meta http-equiv=Content-Type content="text/html; charset=windows-1252">
<meta name=Generator content="Microsoft Word 14 (filtered)">
<style>
<!--
/* Font Definitions */
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Consolas;
panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin-top:0in;
margin-right:0in;
margin-bottom:10.0pt;
margin-left:0in;
line-height:115%;
font-size:11.0pt;
font-family:"Calibri","sans-serif";}
p.MsoPlainText, li.MsoPlainText, div.MsoPlainText
{mso-style-link:"Plain Text Char";
margin:0in;
margin-bottom:.0001pt;
font-size:10.5pt;
font-family:Consolas;}
span.PlainTextChar
{mso-style-name:"Plain Text Char";
mso-style-link:"Plain Text";
font-family:Consolas;}
p.msochpdefault, li.msochpdefault, div.msochpdefault
{mso-style-name:msochpdefault;
margin-right:0in;
margin-left:0in;
font-size:12.0pt;
font-family:"Calibri","sans-serif";}
p.msopapdefault, li.msopapdefault, div.msopapdefault
{mso-style-name:msopapdefault;
margin-right:0in;
margin-bottom:10.0pt;
margin-left:0in;
line-height:115%;
font-size:12.0pt;
font-family:"Times New Roman","serif";}
.MsoChpDefault
{font-size:10.0pt;
font-family:"Calibri","sans-serif";}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 75.1pt 1.0in 75.05pt;}
div.WordSection1
{page:WordSection1;}
-->
</style>
</head>
<body lang=EN-US>
<div class=WordSection1>
<p class=MsoPlainText><b><span style='font-size:28.0pt;font-family:"Courier New"'>Wednesday</span></b></p>
<p class=MsoPlainText><b><span style='font-size:28.0pt;font-family:"Courier New"'>Mothra</span></b><span
style='font-size:28.0pt;font-family:"Courier New"'> will be here today from
10:00 to 4:00</span></p>
<p class=MsoPlainText><span style='font-family:"Courier New"'> </span></p>
</div>
</body>
</html>
我猜这看起来不错! (我在这里的第一篇文章)。
java 很简单,但我想这可能是问题所在:
case QueryService.STATUS_FINISHED:
String results = resultData.getString("results");
// jcb changed
// mResponseContent.setText(results);
wv.loadData(results, "text/html", "utf-8");
感谢大家!
最佳答案
使用这段代码:
wv.loadDataWithBaseURL("", YOUR_HTML, "text/html", "UTF-8", "");
关于java - html页面不会在android api 8 webview中呈现但在浏览器中可以,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30880210/