开发者

How to set the WebChromeClient to open the new page in the same view?

I load the url in the WebView but, when the user click some 开发者_运维知识库button the new url is loaded in the android browser not in my webview. What should I do?

Thanks in advance.


You have to use both WebViewClient and WebChromeClient.

WebChromeClient allows you to get loading progress, for example, whereas WebViewClient will allow you overriding shouldOverrideUrlLoading().

From the WebView page doc:

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();
   }
 });


webchromeClient does not seem to have this ability. Seems silly that WebViewClient can and WebChromeClient can't.


just go through

http://developer.android.com/reference/android/webkit/WebView.html

you will come to know how to use webchromeClient.....

tell me if this help for you...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜