Android/Java - Find text and replace in WebViewClient
I have a WebViewClient that opens in a dialog which i can capture when the URL changes, but on certain URL's I would like to replace certain text but I cant seem to figure out how to get the text of the current webpage that has been loaded so I can search 开发者_如何转开发and replace that text.
Looks like there is already a question about getting the HTML code from a WebView. Please take a look at that: Is it possible to get the HTML code from WebView (Main tutorial is here: http://lexandera.com/2009/01/extracting-html-from-a-webview/)
Of course, once you get the HTML code (string) you can do anything that you want such as replacing the text as you wanted!
Manipulated HTML string can be loaded into the view with following code snippet:
webview.loadData(newHtmlStr, "text/html", "utf-8");
newHtmlStr is the new data and it must be URI-escaped!
精彩评论