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.
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
Delphi:
if MessageDlg ('Message Text', mtConfirmation, [mbYes, mbNo], 0)
Android:
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;
}
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.
confirmation dialog so that the class can be used in class or another activity