=================================
<activity
android:name="com.example.helloproject1.Hopeac2"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
===============
package com.example.helloproject1;
import android.os.Bundle;
import android.app.Activity;
import android.view.View;
import android.widget.*;
import android.webkit.*;
public class Hopeac2 extends Activity
{
private WebView wv1=null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_hopeac2);
wv1=(WebView)findViewById(R.id.webView1);
WebSettings ws=wv1.getSettings();
ws.setJavaScriptEnabled(true);
ws.setBuiltInZoomControls(true);
ws.setJavaScriptCanOpenWindowsAutomatically(true);
wv1.loadUrl("file:///android_asset/ex2.html");
}
}
=====================================================
參考http://www.viralandroid.com/2015/08/simple-android-webview-example.html
===========================================
資源檔
1.檔名不可用數字開頭
2.檔名和副檔名不可以大寫
3.檔名不可以用繁體中文
4.檔名不可以用特殊符號% ,-, #, $, /,^
================================
https://www.eclipse.org/downloads/packages/release/Neon/2
==========================
package com.example.helloproject1;
import android.os.Bundle;
import android.app.Activity;
import android.view.View;
import android.widget.*;
import android.webkit.*;
public class Hopeac2 extends Activity
{
private WebView wv1=null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_hopeac2);
wv1=(WebView)findViewById(R.id.webView1);
WebSettings ws=wv1.getSettings();
ws.setJavaScriptEnabled(true);
ws.setBuiltInZoomControls(true);
ws.setJavaScriptCanOpenWindowsAutomatically(true);
WebChromeClient wcc=new WebChromeClient()
{
@Override
public boolean onJsAlert(WebView view, String url, String message,
JsResult result) {
// TODO Auto-generated method stub
return super.onJsAlert(view, url, message, result);
}
};
wv1.setWebChromeClient(wcc);
wv1.loadUrl("file:///android_asset/dbpageform5.html");
}
}
沒有留言:
張貼留言