Android的web视图shouldOverrideUrlLoading方法 [英] Android Webview shouldOverrideUrlLoading method
问题描述
当是 shouldOverrideUrlLoading
调用的方法?
webView.setWebViewClient(新WebViewClient(){
@覆盖
公共布尔shouldOverrideUrlLoading(web视图查看,字符串URL){
}
});
- 是它的URL的初始加载过程中调用?例如
webView.loadUrl(文件:///android_asset/html/index.html);
- 在它被称为每次中的WebView改变网址?
任何参考?我一个也没找到。谢谢
-
但它确实,被调用时的WebView从一个用户曾要求加载不同的URL。
-
调用
使用loadURL()
也将触发shouldOverrideUrlLoading()
方法。 (只有当一个新的URL即将被载入。)
给主机应用程序有机会接管控制,当一个新的URL是关于当前的WebView加载。的如果 WebViewClient不提供,默认的WebView会问活动 管理器来选择适当的处理程序的URL。如果WebViewClient是 前提是,返回true表示主机应用程序处理的URL, 而返回false表示目前的WebView处理的URL。
编号:<一href="http://developer.android.com/reference/android/webkit/WebViewClient.html#shouldOverrideUrlLoading%28android.webkit.WebView,%20java.lang.String%29"相对=nofollow>公共布尔shouldOverrideUrlLoading(web视图查看,字符串URL)
When is shouldOverrideUrlLoading
method called?
webView.setWebViewClient(new WebViewClient(){
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
}
});
- Is it called during initial loading of url? e.g.
webView.loadUrl( "file:///android_asset/html/index.html");
- Is it called everytime URL of webview changes?
Any reference? I didn't find one. Thanks
It does however, get called when the WebView to load a different URL from the one the user had requested.
Calling
loadUrl()
will also trigger theshouldOverrideUrlLoading()
method. (Only when a new url is about to be loaded.)
Give the host application a chance to take over the control when a new url is about to be loaded in the current WebView. If WebViewClient is not provided, by default WebView will ask Activity Manager to choose the proper handler for the url. If WebViewClient is provided, return true means the host application handles the url, while return false means the current WebView handles the url.
Ref : public boolean shouldOverrideUrlLoading (WebView view, String url)
这篇关于Android的web视图shouldOverrideUrlLoading方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!