Alex Rivera | Logout

Changing HTML in a WebView programmatically

Asked 2012-01-20T07:34:47.943
10

I'm loading an html asset page into a WebView using

webMain.loadUrl("file:///android_asset/record.html");

which works fine, but inside the html are a number of places where I'd like to use information from the app. For instance, the HTML may contain text that reads "[Custom]". Is there a way I can replace that word with information passed from the application?

Edit
Report

1 Answer

4

Yes you can do that by loading your page in a String and then load that string in your WebView.

Eg:

String summary = "<html><body>You scored <b>192</b> points.</body></html>";
webview.loadData(summary, "text/html", null);

Taken from here

answered 2012-01-20T07:42:56.320

Your Answer