dialog 自定義 dialog class 方法
1. 建立 class2. 將程式碼貼進去
3. 搞定
public static void showConfirm(Activity activity, int title, int messageId, DialogInterface.OnClickListener listener) { String message = ""; if (messageId != 0) { message = activity.getString(messageId); } showConfirm(activity, title, message, listener, false, null); } public static void showConfirm(Activity activity, int title, String message, DialogInterface.OnClickListener confirmListener, boolean hasCancel, DialogInterface.OnClickListener cancelListener) { if (activity == null) { return; } AlertDialog.Builder builder = new AlertDialog.Builder(activity); if (title != 0) { builder.setTitle(title); } builder.setCancelable(hasCancel); builder.setMessage(message); builder.setPositiveButton(R.string.confirm, confirmListener); if (hasCancel) { builder.setNegativeButton(android.R.string.cancel, cancelListener); } builder.show(); }
留言
張貼留言