shouldOverrideUrlLoading

shouldOverrideUrlLoading

本文介绍了Android的web视图shouldOverrideUrlLoading方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当是 shouldOverrideUrlLoading 调用的方法?

  webView.setWebViewClient(新WebViewClient(){
    @覆盖
    公共布尔shouldOverrideUrlLoading(web视图查看,字符串URL){


    }
});
 

  1. 是它的URL的初始加载过程中调用?例如 webView.loadUrl(文件:///android_asset/html/index.html);
  2. 在它被称为每次中的WebView改变网址?

任何参考?我一个也没找到。谢谢

解决方案
  1. 但它确实,被调用时的WebView从一个用户曾要求加载不同的URL。

  2. 调用使用loadURL()也将触发 shouldOverrideUrlLoading()方法。 (只有当一个新的URL即将被载入。)

编号:公共布尔shouldOverrideUrlLoading(web视图查看,字符串URL)

When is shouldOverrideUrlLoading method called?

webView.setWebViewClient(new WebViewClient(){
    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url) {


    }
});
  1. Is it called during initial loading of url? e.g. webView.loadUrl( "file:///android_asset/html/index.html");
  2. Is it called everytime URL of webview changes?

Any reference? I didn't find one. Thanks

解决方案
  1. It does however, get called when the WebView to load a different URL from the one the user had requested.

  2. Calling loadUrl() will also trigger the shouldOverrideUrlLoading() method. (Only when a new url is about to be loaded.)

Ref : public boolean shouldOverrideUrlLoading (WebView view, String url)

这篇关于Android的web视图shouldOverrideUrlLoading方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-03 07:16