Go from blog: http://www.cnblogs.com/JuneZhang/p/4148542.html
1. Layout file fragment: Res-layout
<Android:id= "@+id/toweb" android:layout_width= "Fill_parent" android:layout_ Height
2.Java Fragment: src
@OverrideProtectedvoidOnCreate (Bundle savedinstancestate) {Super. OnCreate (Savedinstancestate); Setcontentview (R.layout.activity_main);//WebView WebView browser=(WebView) Findviewbyid (R.id.toweb); Browser.loadurl ("http://www.baidu.com");//Sets the freely scalable Web page browser.getsettings (). Setsupportzoom (True); Browser.getsettings (). Setbuiltinzoomcontrols (True);//If the page is linked, if you want to click on the link to continue responding in the current browser,//Instead of the newly opened Android system browser should be linked, must overwrite WebView webviewclient object Browser.setwebviewclient (NewWebviewclient () {PublicBooleanShouldoverrideurlloading (WebView view, String URL) {//Override this method to indicate that clicking on a link in the Web page or jumping in the current webview does not jump to the browser.View.loadurl (URL);ReturnTrue; } }); }//Go back@OverridePublicBoolean OnKeyDown (IntKeyCode, KeyEvent event) {WebView browser=(WebView) Findviewbyid (R.id.toweb);// Check if the key event is the back button and if there ' s h istory if (keycode = keyevent.keycode_back) && Browser.cangoback ()) {Browser.goback (); return true// return true; // If it wasn ' t the back key or there's no Web page history, b Ubble up to the default // system behavior (probably exit The activity) return super .onkeydown (KeyCode, event);}
3. Androidmanifest.xml set permissions, otherwise cannot access
<!-- Add this permission, WebView can access the Web page- <android:name= "Android.permission.INTERNET" ></uses-permission
Andriod using WebView controls to embed pages in the app