Example usage for android.webkit WebView setFindListener

List of usage examples for android.webkit WebView setFindListener

Introduction

In this page you can find the example usage for android.webkit WebView setFindListener.

Prototype

public void setFindListener(FindListener listener) 

Source Link

Document

Registers the listener to be notified as find-on-page operations progress.

Usage

From source file:com.ywesee.amiko.MainActivity.java

@TargetApi(16)
void setFindListener(final WebView webView) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        webView.setFindListener(new FindListener() {
            @Override//w w w. j  a  v  a2 s  .c om
            public void onFindResultReceived(int activeMatchOrdinal, int numberOfMatches,
                    boolean isDoneCounting) {
                // Update hits counter
                if (isDoneCounting) {
                    if (activeMatchOrdinal < numberOfMatches) {
                        mSearchHitsCntView.setVisibility(View.VISIBLE);
                        mSearchHitsCntView.setText((activeMatchOrdinal + 1) + "/" + numberOfMatches);
                    } else {
                        mSearchHitsCntView.setVisibility(View.GONE);
                        webView.clearMatches();
                    }
                }
            }
        });
    }
}