CustomDialog類與CustomToast類見前兩篇
import cn.pocdoc.exam.listener.OnCustomDialogListener;
import cn.pocdoc.exam.views.CustomDialog;
import cn.pocdoc.exam.views.MyToast;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.view.View.OnClickListener;
public class Pop {
public static void popNoNetWindow(final Context context) {
new CustomDialog(context, CustomDialog.DIALOG_THEME_TWO_BUTTON_NOT_CANCEL).setMessage("網絡連接不可用,請檢查網絡設置")
.setButton("設置", new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = null;
// 判斷手機系統的版本 即API大於10 就是3.0或以上版本
if (android.os.Build.VERSION.SDK_INT > 10) {
intent = new Intent(android.provider.Settings.ACTION_WIRELESS_SETTINGS);
} else {
intent = new Intent();
ComponentName component = new ComponentName("com.android.settings",
"com.android.settings.WirelessSettings");
intent.setComponent(component);
intent.setAction("android.intent.action.VIEW");
}
context.startActivity(intent);
}
}, "取消", null).show();
}
public static void popToast(Context context, String title) {
popToast(context, title, null);
}
public static void popToast(Context context, String title, OnCustomDialogListener listener) {
CustomToast toast = new CustomToast(context<span style="font-family: Arial, Helvetica, sans-serif;">,500,title);</span>
toast.setOnCustomDialogListener(listener);
toast.show();
}
public static void popErrorDialog(final Context context, String errorCode) {
new CustomDialog(context, CustomDialog.DIALOG_THEME_ONE_BUTTON_NOT_CANCEL)
.setMessage(errorCode).setButton("確定", null).show();
}
public static CustomDialog showWaitDialog(Context context) {
return new CustomDialog(context, CustomDialog.DIALOG_THEME_WAIT_NOT_CANCEL).show();
}
}