1 package jp.sourceforge.gokigen.memoma.dialogs;
3 import android.app.AlertDialog;
4 import android.app.Dialog;
5 import android.content.Context;
6 import android.content.DialogInterface;
7 import android.view.LayoutInflater;
8 import android.view.View;
9 import android.widget.TextView;
11 import jp.sourceforge.gokigen.memoma.R;
14 * はい か いいえ を入力するダイアログを準備する
19 public class ConfirmationDialog
21 private Context context;
22 private IResultReceiver resultReceiver = null;
23 private String message = "";
24 private String title = "";
27 public ConfirmationDialog(Context arg)
36 public void prepare(IResultReceiver receiver, int titleIcon, String titleMessage, String confirmMessage)
40 resultReceiver = receiver;
44 message = confirmMessage;
51 public Dialog getDialog()
53 LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
58 final View layout = inflater.inflate(R.layout.confirmationdialog, null);
60 AlertDialog.Builder builder = new AlertDialog.Builder(context);
61 final TextView textView = layout.findViewById(R.id.confirm_message);
63 // 表示するデータ(アイコン、ダイアログタイトル、メッセージ)を準備する
66 builder.setIcon(icon);
70 builder.setTitle(title);
74 textView.setText(message);
76 builder.setView(layout);
77 builder.setCancelable(false);
78 builder.setPositiveButton(context.getString(R.string.confirmYes), new DialogInterface.OnClickListener()
80 public void onClick(DialogInterface dialog, int id)
82 if (resultReceiver != null)
84 resultReceiver.acceptConfirmation();
90 builder.setNegativeButton(context.getString(R.string.confirmNo), new DialogInterface.OnClickListener()
92 public void onClick(DialogInterface dialog, int id)
94 if (resultReceiver != null)
96 resultReceiver.rejectConfirmation();
102 return (builder.create());
105 public interface IResultReceiver
107 void acceptConfirmation();
108 void rejectConfirmation();