Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 997
klanm Avatar asked Mar 06 '26 06:03

klanm


1 Answers

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.

like image 165
user1439970 Avatar answered Mar 07 '26 20:03

user1439970



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!