2011-08-19 80 views
2

即時試圖使用web視圖這樣的:機器人,使用WebView loadData

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"); 

它工作,但是,當附加寬度=在式標籤100%,webView的斜面加載數據。

我用這個參考:http://developer.android.com/reference/android/webkit/WebView.html#loadData(java.lang.String, java.lang.String, java.lang.String)

LOLL,解決了:

html = html.replace("%", "%25"); 
html = html.replace("#", "%23"); 
html = html.replace("\\", "%27"); 
html = html.replace("?", "%3f"); 

回答

1

爲了解決這個devguide的HelloWorld示例,我改變了順序替換電話:

html = html.replace("%", "%25"); 
html = html.replace("#", "%23"); 
html = html.replace("\\", "%27"); 
html = html.replace("?", "%3f");