android WebView 啟用javaScript – Android移動開發技術文章_手機開發 Android移動開發教學課程

 

package com.qiaoning;

 

 

import com.sglnetwork.android.voicepay.R;

 

 

import android.app.Activity;

import android.os.Bundle;

import android.view.View;

import android.webkit.WebSettings;

import android.webkit.WebView;

import android.widget.Button;

import android.widget.Toast;

 

 

public class BindGuidActivity extends Activity{

 

 

//widget

private WebView guideWebView = null;

private Button btnBack = null;

private WebSettings webSettings = null;

 

//val

private String strURL = "";

 

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.bind_guid_layout);

 

initWidget();

initData();

}

 

private void initWidget(){

guideWebView = (WebView)findViewById(R.id.guideWebView);

webSettings = guideWebView.getSettings();

webSettings.setJavaScriptEnabled(true);

btnBack = (Button)findViewById(R.id.btnBack);

btnBack.setOnClickListener(btnBackClickListener);

}

 

private void initData(){

strURL = "";

guideWebView.loadUrl(strURL);

Toast.makeText(BindGuidActivity.this, R.string.loading_url, Toast.LENGTH_LONG).show();

}

 

View.OnClickListener btnBackClickListener = new View.OnClickListener() {

 

@Override

public void onClick(View v) {

BindGuidActivity.this.finish();

}

};

}

摘自 qiaoning13256的專欄

發佈留言