Recreate Find page browser function in web view

I'm trying to recreate the Find on Page feature found in the Android browser, so I can apply it to my webview.

Does anyone know a good place for me to start looking or any hints?

So far, I:

  webView.  findAll ("something");
 try
 {
 Method m = WebView.class.getMethod ("setFindIsUp", Boolean.TYPE);
 m.invoke (webView, true);
 }
 catch (Throwable ignored)
 {
 Log.i ("Error", ignored.toString ());
 }

But this allows only a predefined search. The browser allows you to enter something to search.

I hope there are some examples to work with. I can’t imagine that I am the first who wants to do this.

Any help is much appreciated!

+4
source share
3 answers

If your code already allows a predefined search, all you have to do is get input from the user and use the resulting string instead of "something" in your example.

Here is one of the possible methods using AlertDialog: http://www.androidsnippets.com/prompt-user-input-with-an-alertdialog

+1
source

showFindDialog works great, but only for Android 3.x. Apparently, it does not work for android 4.x ... For Android 2.x use findall ()

+2
source

If you use showFindDialog (queryString, true); everything is done for you on your webview.

+1
source

All Articles