Android编程示例之——WebView,判断JavaScript引擎是V8还是JavaScriptCore

1), Html页面设计:







2),Activity设计

package com.tutor.webwiewdemo;
import android.app.Activity;
import android.content.ComponentName;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.widget.Button;
import android.util.Log;
public class WebViewDemo extends Activity {
private WebView mWebView;
private Button mButton;
public String TAG="WebViewDemo";
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mWebView = (WebView) findViewById(R.id.webview);
WebSettings mWebSettings = mWebView.getSettings();
mWebSettings.setJavaScriptEnabled(true);
mWebView.loadUrl("file:///android_asset/v8jsctest.html");
}
}

3),layout设计


    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
   android:layout_width="160dip" 
   android:layout_height="wrap_content" 
   android:text="V8 or JSC test:"
   />
android:id="@+id/webview"
android:layout_width="fill_parent" 
   android:layout_height="wrap_content" 
/>

 

 

 

 

你可能感兴趣的:(Android,存档2018)