问题描述
我有一个web视图执行搜索时,此code低于Android版本4.0.3的伟大工程,在这个版本和更高的高亮功能不突出。搜索本身的工作和周围跳转的页面,但没有显示的结果(除非你看够硬!)。
我想知道是否有人知道变通,支持比4.0.3更高?
在其他的答案人们联系到这些网页可能的解决方案,但我不知道如何去适应这个我在Android中的WebView。
网页:
http://4umi.com/web/javascript/hilite.php#thescript
http://www.nsftools.com/misc/SearchAndHighlight.htm
code我使用目前搜索和亮点:
公共布尔onKey(视图V,INT关键code,KeyEvent的事件){
如果((event.getAction()== KeyEvent.ACTION_DOWN)
&功放;&安培; ((钥匙code == KeyEvent.KEY code_ENTER))){
wv.findAll(findBox.getText()的toString());
尝试 {
方法M = WebView.class.getMethod(setFindIsUp
Boolean.TYPE);
m.invoke(WV,真正的);
}赶上(异常忽略){
}
}
返回false;
}
在的Android 4.1(软糖), WebView.findAll()
是德precated,我们应使用 WebView.findAllAsync
代替。
祝本帮助:)
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;
}
In Android 4.1(jellybean), WebView.findAll()
is deprecated, we should use WebView.findAllAsync
instead.
Wish this help:)
这篇关于Android的 - 在web视图上面Android版本4.0.3突出显示文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!