0
点赞
收藏
分享

微信扫一扫

Android加载Html的方法


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);

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 = 

"


链接google

"+ 


"



"; 


mWebView.loadDataWithBaseURL("file://", html,mimeType, encoding, "about:blank");

举报

相关推荐

0 条评论