Android WebView click open within WebView not a default browser

后端 未结 12 2010
迷失自我
迷失自我 2020-11-27 16:34

I did one sample application using WebView, in that web view the URL comes from web services. It\'s working fine, but if I click any link within that WebView, its automatica

12条回答
  •  失恋的感觉
    2020-11-27 17:22

    You can always open url within webview by using this:

          @Override
      public void onCreate(Bundle savedInstanceState) {
         webview.setWebViewClient(new MyWebViewClient());
     webview.getSettings().setJavaScriptEnabled(true);
     webview.getSettings().setPluginsEnabled(true);
         }
    
    
         private class MyWebViewClient extends WebViewClient {
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
    
    
                view.loadUrl(url);
                return true;
            }
    
            @Override
            public void onLoadResource(WebView  view, String  url){
    
            }
        }    
    

提交回复
热议问题