Reputation: 87
I have a webview that performs a search, this code works great for below android version 4.0.3, at this version and higher the highlight function fails to highlight. The search itself works and jumps the page around but nothing is shown for the result (Unless you look hard enough!).
I want to know if anyone knows of a work-around that supports higher than 4.0.3?
People in other answers have linked to these webpages as possible solutions but I am not sure how to adapt this to my webview in Android.
WebPages:
http://4umi.com/web/javascript/hilite.php#thescript
http://www.nsftools.com/misc/SearchAndHighlight.htm
Code I am using currently to search and highlight:
public boolean onKey(View v, int keyCode, KeyEvent event) {
if ((event.getAction() == KeyEvent.ACTION_DOWN)
&& ((keyCode == KeyEvent.KEYCODE_ENTER))) {
wv.findAll(findBox.getText().toString());
try {
Method m = WebView.class.getMethod("setFindIsUp",
Boolean.TYPE);
m.invoke(wv, true);
} catch (Exception ignored) {
}
}
return false;
}
Upvotes: 3
Views: 4808