WebView.PictureListener 加载事件及完成更新

来源:互联网 发布:蛇精脸拍照软件 编辑:程序博客网 时间:2024/06/03 12:12
步骤:
1 创建 一个 自己的WebViewClient(继承 WebViewClient 类)如 MyWebviewclient
2 重载 里面的 onPageFinished(WebView view, String url)方法,(webview加载完成会调用这个方法),这个方法放自己想要做的事情,在webview加载完成以后

3 关联 你自己的webviewclient 与 webview 通过 这个方法:webView.setWebViewClient( new MyViewerWebViewClient();


通常是按上面这样做的,但是When onPageFinished() is called, the rendering picture may not be updated yet.意思大致为,页面加载好了,webview所对应的显示图片还没有更新

要想响应这个事件可以使用

mWebView.setPictureListener(new PictureListener() {
            @Override
            public void onNewPicture(WebView view, Picture picture) {
                  System.out.println("onNewPicture");
            }
        });

但是his method is deprecated. Due to internal changes, the picture does not include composited layers such as fixed position elements or scrollable divs. While the PictureListener API can still be used to detect changes in the WebView content, you are advised against its usage until a replacement is provided in a future Android release

这个方法已经被弃用,这个对应的picture并不包含复合层或可以滚动的Div,只能被使用来侦测WebView内容的变化.在以后的版本会提供他的替代事件


原创粉丝点击