문제

I'm using shouldoverrideurlloading to trigger a function when a link is clicked in my webview. Is their a way to stop the webview from loading a new screen when the link is clicked. All I want to do is run the function NetworkOperations.addlike(url) when a user clicks the link not load a new page in webview

EX:

 public boolean shouldOverrideUrlLoading(WebView view, String url)
        {

            if (url.endsWith("&like"))
            {

                NetworkOperations.addlike(url);
                Break;

            }
         }
도움이 되었습니까?

해결책

If you return true it should NOT load the url in the WebView, while false will let the WebView load the page.

public boolean shouldOverrideUrlLoading(WebView view, String url) {
  if (url.endsWith("&like")) {
    NetworkOperations.addlike(url);
    return false;
  } else {
    return true;
  }
}

Android Documentation

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top