First, add the webview control to the XML file in the layout folder.
<Webview <br/> Android: Id = "@ + ID/wv1" <br/> Android: layout_width = "fill_parent" <br/> Android: layout_height = "fill_parent" <br/>
Enter the following in the main file:Code
Public class testdemo extends activity {<br/>/** called when the activity is first created. */</P> <p> @ override <br/> Public void oncreate (bundle savedinstancestate) {<br/> super. oncreate (savedinstancestate); <br/> setcontentview (R. layout. main); </P> <p> webview wview = (webview) findviewbyid (R. id. wv1); <br/> websettings Wset = wview. getsettings (); <br/> Wset. setjavascriptenabled (true); </P> <p> // wview. loadurl ("file: // android_asset/index.html"); <br/> // wview. loadurl ("content: // com.android.html fileprovider/sdcard/index.html"); <br/> wview. loadurl ("http://wap.baidu.com"); </P> <p >}< br/>
// Wview. loadurl ("File: // android_asset/index.html");
-----Open the index.html file under the assetdirectory of this package
// Wview. loadurl ("content: // com.android.html fileprovider/sdcard/index.html ");
-----Open the SDK index.html File
// Wview. loadurl ("Http://wap.baidu.com");
----- Open the HTML file of the specified URL