2.Android 加载应用程序内置页面

package com.example.webview;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.webkit.WebView;

public class MainActivity extends Activity {
    private WebView myWebView;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		//加载应用程序内置页面
		/*
		 * Android内置了一个前缀为file:///android_asset/"的结构,webView会根据这个结构到应用程序下
		 * 的assets文件夹下寻找加载的页面*/
		myWebView=(WebView)findViewById(R.id.webView1);
		myWebView.loadUrl("file:///android_asset/baidu.html");
		
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}

}

你可能感兴趣的:(2.Android 加载应用程序内置页面)