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