2011-05-04 80 views
1

嘗試呈現從webservice傳遞的html以使用loadData/loadDataWithBaseURL顯示在webView中。Webview loadDataWithBaseURL不顯示html android

我已經編碼了html字符串TextUtils.htmlEncode並將其包裝在<html> <body>但是沒有任何顯示。

mMessageDetailsHtmlString = &lt;html&gt;&lt;body&gt;&lt;div style=&quot;color:#ffffff&quot; align=&quot;center&quot;&gt;&lt;h3&gt;Test Promo&lt;/h3&gt;&lt;/div&gt;&lt;p style=&quot;color:#ffffff&quot;&gt;Here is some text about a great test promo.&lt;/p&gt;&lt;p style=&quot;color:#ffffff&quot;It includes an image (below) using a fully qualified URL&lt;p&gt;&lt;p style=&quot;color:#ffffff&quot;&gt;&lt;img href=&quot;http://myserver.com/media/images/img-logo.png&quot; /&gt;&lt;/p&gt;&lt;p style=&quot;color:#ffffff&quot;&gt;This is a test message with white text&lt;/p&gt;&lt;/body&gt;&lt;/html&gt; 

//used loadDataWithBaseURL with a fake base url as loadData didn't work 
mWebView.loadDataWithBaseURL("http://null", mMessageDetailsHtmlString, "text/html", "utf-8", null); 

回答

1

看看那個html中的文本是白色的,你的webview的背景是否也是白色的?

嘗試mWebView.setBackgroundColor(Color.BLUE);

+0

omg!完全錯過了我的html文本是白色的事實,謝謝 – scottyab 2011-05-04 15:41:30

相關問題