📜  andorid studio webview 应用程序喜欢单击新标签打开停止 - 无论代码示例

📅  最后修改于: 2022-03-11 14:59:18.247000             🧑  作者: Mango

代码示例1
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    String url ="http://dirtywasted.com/";
    WebView view=(WebView) this.findViewById(R.id.webView);
    view.getSettings().setJavaScriptEnabled(true);
    view.setWebViewClient(new WebViewClient() {
            @Override
            public bool shouldOverrideUrlLoading(WebView view, String url) {
                //url will be the url that you click in your webview.
                //you can open it with your own webview or do
                //whatever you want

                //Here is the example that you open it your own webview.
                view.loadUrl(url);
                return true;
            }       
         });
    view.loadUrl(url);
}