Android webview: highlight a specific word in a page using javascript?

前端 未结 4 1822
暖寄归人
暖寄归人 2020-12-09 07:24

i am using a webview inside my android application. I would like to know if it is possible to highlight or underline a specific word/sentence/paragraph in a loaded page usin

4条回答
  •  春和景丽
    2020-12-09 08:01

    findAll() is deprecated! You can use findAllAsync() from API16 onwards in a simple manner like this:

    webView.setWebViewClient(new WebViewClient(){
                @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
                @Override
                public void onPageFinished(WebView view, String url) {
                    if (searchText != null && !searchText.equals("")) {
                        webView.findAllAsync(searchText);
                    }
                }
            });
    

提交回复
热议问题