什么是此代码中的返回类型语句

时间:2017-07-19 16:46:55

标签: android sdk

我应该在此处删除错误?

webView.setWebViewClient(new WebViewClient(){
        @Override
        public void onPageFinished(WebView view, String url) {
            swipe.setRefreshing(false);
        }
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String urlNewString)  {
            currentURL = urlNewString;
        }//here is error for return type
});

2 个答案:

答案 0 :(得分:0)

如果主机应用程序想要离开当前的WebView并处理url本身,则从WebViewClient设置返回类型为True,否则返回false。

     @Override
    public boolean shouldOverrideUrlLoading(WebView view, String urlNewString)  
     {
        currentURL = urlNewString;
        return true;
        //return true load with system-default-browser or other browsers, false with your webView

    }

答案 1 :(得分:0)

如果您想覆盖加载URI或true,则必须返回false

@Override
public boolean shouldOverrideUrlLoading(WebView view, String urlNewString)  {
    currentURL = urlNewString;
    return true; //or false
}