android访问html页面_html/css_WEB-ITnose

WBOY
Release: 2016-06-21 08:49:28
Original
1217 people have browsed it

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, "执行结束..");    }     }
Copy after login

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>
Copy after login


Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template