简体   繁体   English

Android工作室:每URL在WebView开

[英]Android Studio: Open every URL in WebView

I want to turn a website into an app using the WebView. However, if I tap a link in the WebView, the app does not try to load the URL in the WebView, but in the browser (Chrome).我想使用 WebView 将网站变成应用程序。但是,如果我点击 WebView 中的链接,该应用程序不会尝试在 WebView 中加载 URL,而是在浏览器 (Chrome) 中加载。 How can I change this?我怎样才能改变这个?

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    WebView webView = (WebView) findViewById(R.id.webView);
    webView.getSettings().setJavaScriptEnabled(true);
    webView.loadUrl("https://100315.fuxnoten.online/webinfo/account/");
}

You can use setWebViewClient()您可以使用setWebViewClient()

WebView webView = (WebView) findViewById(R.id.webView);
webView.setWebViewClient(new WebViewClient());
...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM