Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/201.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何设置WebChromeClient以在同一视图中打开新页面?_Android - Fatal编程技术网

Android 如何设置WebChromeClient以在同一视图中打开新页面?

Android 如何设置WebChromeClient以在同一视图中打开新页面?,android,Android,我在WebView中加载url,但当用户单击某个按钮时,新url将加载到android浏览器中,而不是我的WebView中。我该怎么办 提前谢谢。请过目 您将了解如何使用webchromeClient 请告诉我是否有此帮助…webchromeClient似乎没有此功能。WebViewClient可以而WebChromeClient不能似乎很愚蠢。您必须同时使用WebViewClient和WebChromeClient 例如,WebChromeClient允许您获取加载进度,而WebViewCl

我在WebView中加载url,但当用户单击某个按钮时,新url将加载到android浏览器中,而不是我的WebView中。我该怎么办

提前谢谢。

请过目

您将了解如何使用webchromeClient


请告诉我是否有此帮助…

webchromeClient似乎没有此功能。WebViewClient可以而WebChromeClient不能似乎很愚蠢。

您必须同时使用WebViewClientWebChromeClient

例如,WebChromeClient允许您获取加载进度,而WebViewClient将允许您覆盖shouldOverrideUrlLoading()

从WebView页面文档:

webview.setWebChromeClient(new WebChromeClient() {
   public void onProgressChanged(WebView view, int progress) {
     // Activities and WebViews measure progress with different scales.
     // The progress meter will automatically disappear when we reach 100%
     activity.setProgress(progress * 1000);
   }
 });
 webview.setWebViewClient(new WebViewClient() {
   public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
     Toast.makeText(activity, "Oh no! " + description, Toast.LENGTH_SHORT).show();
   }
 });

可能的重复项不重复,我的对象不是WebViewClient,它是WebChromeClient,此对象没有shouldOverrideUrlLoading方法。