WebView webView = FindViewById<WebView>(Resource.Id.webView1);
webView.HorizontalScrollBarEnabled = false;
webView.LoadUrl("res.htm");
如何更改我的文件中的某些HTML代碼並使用webView在不更改物理文件的情況下顯示它?如何更改WebView(Monodroid)中的HTML代碼
WebView webView = FindViewById<WebView>(Resource.Id.webView1);
webView.HorizontalScrollBarEnabled = false;
webView.LoadUrl("res.htm");
如何更改我的文件中的某些HTML代碼並使用webView在不更改物理文件的情況下顯示它?如何更改WebView(Monodroid)中的HTML代碼
您可以使用此代碼將html加載爲字符串。
var htmlView = new WebView(context);
htmlView.LoadData(htmlMarkup, "text/html", "utf-8");
我試圖這樣做: StreamReader reader = new StreamReader(Assets.Open(「res.htm」)); string webString = reader.ReadToEnd(); webView.LoadData(webString,「text/html」,「utf-8」); 但它沒有工作。 webView顯示我的代碼沒有風格 – NoEscape
你想加載資產?看看這個。 http://stackoverflow.com/questions/5320288/displaying-android-asset-files-in-a-webview – animaonline
您可以將文件加載到字符串中..解析該字符串並更改所需的任何HTML,然後將WebView設置爲該更改的HTML字符串。 – dymmeh