Home  >  Article  >  Web Front-end  >  android访问html页面_html/css_WEB-ITnose

android访问html页面_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-21 08:49:281179browse

Activity代码如下:

package com.example.reg; import android.app.Activity;import android.os.Bundle;import android.util.Log;import android.webkit.WebView; public class WebViewActivity extends Activity{         private static final String tag = WebViewActivity.class.getSimpleName();     @Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.webview);        WebView webview = (WebView) findViewById(R.id.web_view);        webview.getSettings().setJavaScriptEnabled(true);        //webview.loadUrl("http://www.baidu.com");        //用file://来指定本地文件        webview.loadUrl("file:///android_asset/html/test.html");        Log.d(tag, "执行结束..");    }     }

html页面路径:

\reg\assets\index.html   \reg 为项目名称

HTML代码如下:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html><head>    <title>Hello First Html..</title> </head><body>    First Html</body></html>


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn