title: create confirm dialog class on android
body: <p>i try to make own confirm dialog class with boolean value as result. i have read any tutorial or suggestion but the results are not as I want.</p>
  
  <p>The problem is I hate to write long coding, I wanted to write a simple coding. This comparison delphi to android in writing confirmation dialog</p>
  
  <p>Delphi: </p>
  
  <p><code>if MessageDlg ('Message Text', mtConfirmation, [mbYes, mbNo], 0)</code></p>
  
  <p>Android:</p>
  
  <pre><code>boolean answer = false;
  
  public boolean Confirm (Activity act, String Title, String ConfirmText,
  CancelBtn String, String OkBtn) {
    AlertDialog dialog = new AlertDialog.Builder (act). Create ();
    dialog.setTitle (Title);
    dialog.setMessage (ConfirmText);
    dialog.setCancelable (false);
    dialog.setButton (DialogInterface.BUTTON_POSITIVE, OkBtn,
    new DialogInterface.OnClickListener () {
      public void onClick (DialogInterface dialog, int buttonId) {
    answer = true;
    }
  });
  dialog.setButton (DialogInterface.BUTTON_NEGATIVE, CancelBtn,
  new DialogInterface.OnClickListener () {
    public void onClick (DialogInterface dialog, int buttonId) {
      answer = false;
    }
  });
  dialog.setIcon (android.R.drawable.ic_dialog_alert);
  return answer;
  }
  </code></pre>
  
  <p>the question is can I create a class that generate a confirmation dialogue will produce a Boolean value true or false, just as in Delphi.</p>
  
  <p>confirmation dialog so that the class can be used in class or another activity</p>