koch.trier
koch.trier

Reputation: 600

How to enable Addressbar in Android WebView?

I´m actually using a WebView in my Application and it works pretty good. Now I´d like to be able to change the actual URL, just like that Addressbar in the Android Stock browser, where you can see the URL and where you simply can change it.

How can I enable this bar? Or do I have to implement it myself?! Thanks!

My Code looks like:

private void setupWebView() {
    webview = new WebView(this);
    webview.setWebViewClient(new MyWebViewClient());
    WebSettings webSettings = webview.getSettings();
    webSettings.setUserAgentString("foo");
    webSettings.setJavaScriptEnabled(true);
    webSettings.setAppCacheEnabled(false);
    webSettings.setBuiltInZoomControls(true);
    webview.setWebChromeClient(new WebChromeClient() {
        public void onProgressChanged(WebView view, int progress) {
            MyActivity.this.setProgress(progress * 100);
        }
    });
}

Upvotes: 7

Views: 8770

Answers (1)

Waza_Be
Waza_Be

Reputation: 39538

Impossible:

The WebView class is an extension of Android's View class that allows you to display web pages as a part of your activity layout. It does not include any features of a fully developed web browser, such as navigation controls or an address bar. All that WebView does, by default, is show a web page.

http://developer.android.com/guide/webapps/webview.html

If you want to change URL by code:

WebView myWebView = (WebView) findViewById(R.id.webview);
myWebView.loadUrl("http://www.example.com");

Upvotes: 9

Related Questions