編輯:關於Android編程
package com.html;
import com.sqlite.Dao.NcpRegisterDAO;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.webkit.JsResult;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.widget.Toast;
public class Register_protocolActivity extends Activity {
private Handler mHandler = new Handler();
private WebView mWebView;
private NcpRegisterDAO dao = null;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//踩上一腳,記錄有了就知道復位的時候要去哪裡
dao = new NcpRegisterDAO(Register_protocolActivity.this);
String name = "MainActivity";
dao.add_Stepped(name);
//隱藏標題欄
//requestWindowFeature(Window.FEATURE_NO_TITLE);
//隱藏狀態欄
//getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
//該ACTIVITY不需要layout設置,所以直接指向MainActivity的main
setContentView(R.layout.protocol);
//將WebView實例化
mWebView = (WebView) this.findViewById(R.id.webView);
//WebView打開權限
mWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
mWebView.getSettings().setJavaScriptEnabled(true);
//WebView,SWF文件運行權限
mWebView.getSettings().setPluginsEnabled(true);
mWebView.addJavascriptInterface(new Action(), "ncp");
mWebView.loadUrl("file:///android_asset/protocol.html");
// 創建WebViewChromeClient
WebChromeClient wvcc = new WebChromeClient() {
// 處理Alert事件
public boolean onJsAlert(WebView view, String url, String message, final JsResult result) {
// 構建一個Builder來顯示網頁中的alert對話框
Builder builder = new Builder(Register_protocolActivity.this);
builder.setTitle("計算1+2的值");
builder.setMessage(message);
builder.setPositiveButton(android.R.string.ok, new AlertDialog.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
result.confirm();
}
});
builder.setCancelable(false);
builder.create();
builder.show();
return true;
}
// 處理Confirm事件
public boolean onJsConfirm(WebView view, String url, String message, final JsResult result) {
Builder builder = new Builder(Register_protocolActivity.this);
builder.setTitle("退出確認");
builder.setMessage(message);
builder.setPositiveButton(android.R.string.ok, new AlertDialog.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
//result.confirm();
// 從協義開始到發送注冊信息,這些步驟退出後直接清零復位表,不然如果非正常關機後再重啟會再次進入該頁
dao.Clear_NcpStep_Set0();
finish();
}
});
builder.setNeutralButton(android.R.string.cancel, new AlertDialog.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
result.cancel();
}
});
builder.setCancelable(false);
builder.create();
builder.show();
return true;
}
};
// 設置setWebChromeClient對象
mWebView.setWebChromeClient(wvcc);
}
final class Action {
Action() {
}
public void clickOnAndroid_register() {
mHandler.post(new Runnable() {
public void run() {
// mWebView.loadUrl("javascript:wave()");
Toast.makeText(getBaseContext(), "歡迎進入注冊!", Toast.LENGTH_SHORT).show();
//Intent intent = new Intent(MainActivity.this,Register.class);
Intent intent = new Intent(Register_protocolActivity.this,Register_IDcard.class);
Register_protocolActivity.this.startActivity(intent);
//設置切換動畫,從右邊進入,左邊退出
overridePendingTransition(R.xml.in_from_right, R.xml.out_to_left);
}
});
}
public void clickOnAndroid_quit() {
mHandler.post(new Runnable() {
public void run() {
finish();
}
});
}
}
//禁止回退
public void onBackPressed() {
// TODO Auto-generated method stub
return;
//super.onBackPressed();
}
@Override
protected void onStop() {
super.onStop();
System.out.println("onStop!!");
finish();
// The activity is no longer visible (it is now "stopped")
}
}
分享到:
概述:一般情況下,我們知道View類有個View.OnTouchListener內部接口,通過重寫他的onTouch(View v, MotionEvent event)
問題一、android系統支持什麼字體庫?1、Android系統默認支持三類字體家族,分別為:“serif”,“sans-serif&
下面的截圖……哎,因為1080P在Windows 10上雖然適配了,但大部分軟件並沒有跟上,比如某個錄制GIF的軟件,所以這裡有一定的偏移導致
gravity 這個英文單詞是重心的意思,在這裡就表示停靠位置的意思。 android:gravity 和 android:layout_gravity 的區別: and