xml:
<?xml version="1.0" encoding="UTF-8"?>
<AbsoluteLayout android:orientation="vertical" android:id="@+id/tab1" android:layout_width="fill_parent" android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<WebView android:id="@+id/wv"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_x="0.0dip"
android:layout_y="0.0dip"
android:layout_weight="1.0" />
</AbsoluteLayout>
java:
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
WebView wView = (WebView)findViewById(R.id.wv);
WebSettings wSet = wView.getSettings();
wSet.setJavaScriptEnabled(true);
wView.loadUrl("file:///android_asset/www/index.html");
//wView.loadUrl("content://com.android.htmlfileprovider/sdcard/index.html");
// wView.loadUrl("http://www.baidu.com");
}
}
html:
<!DOCTYPE HTML>
<html>
<head>
<meta name="viewport" content="width=device-width,initial-scale=1" />
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>PhoneGap</title>
<link rel="stylesheet" href="jquery.mobile-1.3.1.css">
<script type="text/javascript" charset="utf-8" src="jquery-1.9.0.min.js"></script>
<script type="text/javascript" charset="utf-8" src="jquery.mobile-1.3.1.js"></script>
</head>
<body>
<div data-role="page">
<div data-role="header">页头</div>
<div data-role="content">内容</div>
<div data-role="footer">页脚</div>
</div>
</body>
</html>