Android - why webview redirect to webbrowser

前端 未结 1 1286
不思量自难忘°
不思量自难忘° 2020-12-19 15:20

i try a simple webView appication. and this is my code :

    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    se         


        
相关标签:
1条回答
  • 2020-12-19 16:00

    You have to override the standard behavior, which launches the browser when links are clicked. Use a WebViewClient's shouldOverrideUrlLoading(). There is an example of this in the SDK (copied below for convenience).

    private class HelloWebViewClient extends WebViewClient {
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.loadUrl(url);
            return true;
        }
    }
    

    ...then you just call someWebView.setWebViewClient(new HelloWebViewClient());.

    0 讨论(0)
提交回复
热议问题