Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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);
        }
    });
}
like image 712
koch.trier Avatar asked Aug 08 '11 18:08

koch.trier


1 Answers

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");
like image 166
Waza_Be Avatar answered Oct 22 '22 03:10

Waza_Be