我在我的活动中有一个Webview。现在,当我使用WebView.findAll()
方法在Webview中搜索文本时,它不会突出显示匹配的单词。
在Android 1.6中,这个方法很好用,但在2.2中不起作用。
我在我的活动中有一个Webview。现在,当我使用WebView.findAll()
方法在Webview中搜索文本时,它不会突出显示匹配的单词。
在Android 1.6中,这个方法很好用,但在2.2中不起作用。
关于这个问题在Android问题跟踪器上有记录:http://code.google.com/p/android/issues/detail?id=9018
我在WebView.findAll()
之后加入了下面的代码,它使得高亮功能可以正常使用:
try
{
Method m = WebView.class.getMethod("setFindIsUp", Boolean.TYPE);
m.invoke(webView, true);
}
catch (Throwable ignored){}
try{
//Can't use getMethod() as it's a private method
for(Method m : WebView.class.getDeclaredMethods()){
if(m.getName().equals("setFindIsUp")){
m.setAccessible(true);
m.invoke(view, true);
break;
}
}
}catch(Exception ignored){}