user3398380
user3398380

Reputation: 39

search text within a webView doesn't work

I'm using this code to search words within in a textView. The buttons and the EditText are displayed but they don't work. In the code there is a warning that says

The method findAll(String) from the type WebView is deprecated

for the line

wv.findAll(findBox.getText().toString());

The rest of the code is in this link.

Upvotes: 1

Views: 1133

Answers (1)

anthonycr
anthonycr

Reputation: 4186

Use

wv.findAll(findBox.getText().toString());

for API versions < 16 and Use

wv.findAllAsync(findBox.getText().toString());

for API versions > 16.

Use the following code to ensure that your code works on all versions:

int API = android.os.Build.VERSION.SDK_INT;
if(API < 16) {
    wv.findAll(findBox.getText().toString());
} else {
    wv.findAllAsync(findBox.getText().toString());
}

Upvotes: 3

Related Questions