1
WebView webView = FindViewById<WebView>(Resource.Id.webView1);
webView.HorizontalScrollBarEnabled = false;
webView.LoadUrl("res.htm");

How to change some pieces of HTML code in my file and show it with webView without physical file changing?

Dave Zych
  • 21,581
  • 7
  • 51
  • 66
NoEscape
  • 211
  • 1
  • 10
  • 2
    You can load the file into a String.. parse that String and change whatever HTML you need, and then set the WebView to that changed HTML string. – dymmeh Feb 04 '13 at 17:50

1 Answers1

0

You can load html as a string by using this code.

var htmlView = new WebView(context);
htmlView.LoadData(htmlMarkup, "text/html", "utf-8");
animaonline
  • 3,715
  • 5
  • 30
  • 57
  • I tried to do this: StreamReader reader = new StreamReader( Assets.Open("res.htm")); string webString = reader.ReadToEnd(); webView.LoadData(webString, "text/html", "utf-8"); but it didnt work. webView showed me code without style – NoEscape Feb 05 '13 at 11:22
  • Are you trying to load an asset? Check out this. http://stackoverflow.com/questions/5320288/displaying-android-asset-files-in-a-webview – animaonline Feb 05 '13 at 11:25