About Android Call page Hide Address bar

Source: Internet
Author: User

First create the project, in Main.xml

Add a good WebView control r.id to Webview1.

Hellowebview.java Code

Package liu.ming.com;

Import android.app.Activity;
Import Android.os.Bundle;
Import android.view.KeyEvent;
Import Android.webkit.WebView;
Import android.webkit.WebViewClient;

public class Hellowebview extends Activity {
WebView Mwebview;
/** called when the activity is first created. */
@Override
public void OnCreate (Bundle savedinstancestate) {
Super.oncreate (savedinstancestate);
Setcontentview (R.layout.main);

Mwebview = (WebView) Findviewbyid (R.ID.WEBVIEW1);
Mwebview.getsettings (). Setjavascriptenabled (True);
Mwebview.loadurl ("http://wap.baidu.com");

Mwebview.setwebviewclient (New Hellowebviewclient ());
}

Private class Hellowebviewclient extends webviewclient{
Display the page in WebView instead of the default browser
@Override
public boolean shouldoverrideurlloading (WebView view, String URL) {
TODO auto-generated Method Stub

View.loadurl (URL);
return true;
}

}

The following code is not added, the address bar is also hidden in my phone, but some devices may have to add these

@Override
public boolean onKeyDown (int keycode, keyevent event) {
TODO auto-generated Method Stub
if ((keycode = = keyevent.keycode_back) && mwebview.cangoback ())
{
Mwebview.goback ();
return true;
}
Return Super.onkeydown (KeyCode, event);
}
}

If you want no titlebar, you have to build a style.xml under value/.

<?xml version= "1.0" encoding= "Utf-8"?>
<resources>
<style name= "Newtheme" parent= "@android: Style/theme.notitlebar" >

</style>
</resources>
At the same time to make your Web page has the Internet function and hidden titlebar, you need to add in the Androidmanifesti.xml

<activity android:name= ". Hellowebview "
Android:label= "@string/app_name"
Android:theme= "@android: Style/theme.notitlebar"
>

This paragraph should hide the title

Be aware that device access is changed to allow access to the Internet

Add to <application> outside

<uses-permission android:name= "Android.permission.INTERNET"/>

This will allow the browser to hide the address bar when the page is displayed.

The above code has been tested and fully available.

About Android Call page Hide Address bar

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.