klanm
klanm

Reputation: 3278

Android:cannot make a selection after WebView search with highlight

Hello I have a bug in my app and I cannot figure it out.

I want to search for text in my WebView and get the found Text highlighted

for Android 1.5-2.3 this works quite well

public void onClick(View v){  
        webView1.findNext(true);

        int i = webView1.findAll(findBox.getText().toString()); 

        try{  
        Method m = WebView.class.getMethod("setFindIsUp", Boolean.TYPE);  
        m.invoke(webView1, true);  
        }catch(Exception ignored){}  
        } 
}

for Android 3.0+ I have to use the JavaScript workaround from here, because Google doesn't support the highlighting of searched text for incomprehensible reasons

And now my Bug: After the search on my WebView I get the highlighted Text, and I can't select the Text anymore. The only fix I could use is the JavaScript workaround in older Android versions, too. But the function runs very slow and it takes about 10 seconds until the text gets highlighted. I Hope someone has a better solution/fix :)

Thank you

Upvotes: 3

Views: 1610

Answers (4)

Mohammad
Mohammad

Reputation: 68

use findAllAsync() instead , finAll() is deprecated in API 16;

Upvotes: 0

timothepoznanski
timothepoznanski

Reputation: 1112

For Android 3.x I used webview.showFindDialog(stringtofind, true);

Upvotes: 0

user1439970
user1439970

Reputation: 31

I use the same for 3.x then it did not work on 4.0.x. Yesterday I updated to 4.0.4 and now highlight works again.

So the solution can be found in the 4.0.4 sources.

Upvotes: 1

klanm
klanm

Reputation: 3278

OK I have found a quite good solution.

Here is a JavaScript code for Highlighting, that runs really fast :) http://4umi.com/web/javascript/hilite.php#thescript

Anyway I don't understand, why I can't selecting text after the of the official Webview search

Upvotes: 0

Related Questions