1.跳转到浏览器直接访问页面,这段代码是在Activity中拷贝来的,所以有startActivity()方法
Uri uri = Uri.parse("http://www.XXXX.com"); //要链接的地址
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
2.使用TextView显示HTML方法
TextView text1 = (TextView)findViewById(R.id.TextView02);
text1.setText(Html.fromHtml(“网页内容”));
3.直接使用android中自带的显示网页组件WebView
webview = (WebView) findViewById(R.id.WebView01);
webview.getSettings().setJavaScriptEnabled(true);
webview.loadUrl("http://www.xxxx.com ");4 显示本地html
@1
webview = (WebView) findViewById(R.id.webview);
webview.getSettings().setJavaScriptEnabled(true);
webview.loadUrl("content://com.android.htmlfileprovider/sdcard/index.html");
@2
Uri uri = Uri.parse("content://com.android.htmlfileprovider/sdcard/01.htm");
Intent intent = new Intent();
intent.setData(uri);
intent.setClassName("com.android.htmlviewer", "com.android.htmlviewer.HTMLViewerActivity");
startActivity(intent);
@3
String encoding = "UTF-8";
String mimeType = "text/html";
final String html =
" "+
" ";
mWebView.loadDataWithBaseURL("file://", html,mimeType, encoding, "about:blank");