-1

Possible Duplicate:
android webview click opens default browser

I have Webview that works for bringing in site, but when I click on links other than the original link it opens a browser. Is there any way to have those links reopen/load within the same webview? Is there a WebView options for this?

Community
  • 1
  • 1
Android Developer
  • 523
  • 2
  • 5
  • 17

1 Answers1

1

it is easy.

1.first, you should write your own WebViewClient, eg:

class MyWebViewClient extends WebViewClient {
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.loadUrl(url);
            return super.shouldOverrideUrlLoading(view, url);
        }
    }

2.now ,you can use it in your Activity, eg:

WebView view = (WebView) findViewById(R.id.webView1);
view.setWebViewClient(new MyWebViewClient());
    view.loadUrl("http://www.baidu.com");

Hope can help you !

alex
  • 11
  • 3