To change the project to the Android version, use the webview class:
1. You must configure the following in androidmanifest. xml:
The purpose is to allow the control to access browser resources.
</activity> </application> <uses-permission android:name="android.permission.INTERNET" />
2. configure a webview (layout folder, Main. XML) in the configuration file you want to load ):
<TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello" /> <WebView android:id="@+id/WebView01" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/webview" />
3. The logic code is as follows:
Private webview;
Private string url = "file: // android_asset/show.html ";
// The show.html file must be placed in the asset directory of the project file
// URL = "content: // com.android.html fileprovider/sdcard/index.html ";
-----Open the SDK index.html File
// URL = ("http://wap.baidu.com );
----- Open the HTML file of the specified URL
.
.
.
Webview = (webview) findviewbyid (R. Id. webview01); webview. getsettings (). setjavascriptenabled (true); webview. loadurl (URL );
4. other methods to access the Web or resources:
Access through URL directly:
Uri uri = Uri.parse("http://www.example.com"); Intent intent = new Intent(Intent.ACTION_VIEW, uri); startActivity(intent);
2. Use textview to display HTML
Textview text1 = (textview) findviewbyid (R. Id. textview02); text1.settext (html. fromhtml ("<font size = '20'> webpage content </font> "));