Delphi xe7 android 中的 Messagedlg

Messagedlg in Delphi xe7 android

我只是想执行安装 Delphi xe7 时给出的示例,android 平台上的 MessageAlerts,不幸的是它不起作用,它给出了以下错误消息:

Blocking Dialogs not implemented in this platform

procedure TMessageAlertsForm.btnMultiButtonAlertClick(Sender: TObject);
begin
  { Show a multiple-button alert that triggers different code blocks according to
    your input }
  case MessageDlg('Choose a button:', System.UITypes.TMsgDlgType.mtInformation,
    [
      System.UITypes.TMsgDlgBtn.mbYes,
      System.UITypes.TMsgDlgBtn.mbNo,
      System.UITypes.TMsgDlgBtn.mbCancel
    ], 0) of
    { Detect which button was pushed and show a different message }
    mrYES:
      ShowMessage('You chose Yes');
    mrNo:
      ShowMessage('You chose No');
    mrCancel:
      ShowMessage('You chose Cancel');
  end;
end;

知道如何解决吗?

这在 XE7 发行说明中有解释:

Dialog Box Methods Support Anonymous Methods to Handle Their Closing

In XE6, calls to dialog box methods (InputBox, InputQuery, MessageDlg, ShowMessage) were always blocking. Any code after a call to one of these methods is not executed until the dialog box closes. Android does not allow blocking dialog boxes, so you could not use these methods on Android.

On XE7, InputBox, InputQuery, and MessageDlg support a new optional parameter, ACloseDialogProc. Calls that include this new parameter work on all platforms, including Android. This new optional parameter allows you to provide an anonymous method that is called when the dialog box closes. When you call these methods using this new parameter, your call is blocking in desktop platforms and non-blocking in mobile platforms. If you need to execute code after your dialog box closes, use this new parameter to ensure that your application works as expected on all supported platforms.

...

ShowMessage also gained support for Android in XE7, and calls to ShowMessage are blocking on desktop platforms and non-blocking on mobile platforms. However, ShowMessage does not provide any new parameter to handle its closing. If you need to execute code after the dialog box that ShowMessage shows closes, use MessageDlg instead of ShowMessage.

例如:

procedure TMessageAlertsForm.btnMultiButtonAlertClick(Sender: TObject);
begin
  MessageDlg('Choose a button:', System.UITypes.TMsgDlgType.mtInformation,
    [
      System.UITypes.TMsgDlgBtn.mbYes,
      System.UITypes.TMsgDlgBtn.mbNo,
      System.UITypes.TMsgDlgBtn.mbCancel
    ], 0,
    procedure(const AResult: System.UITypes.TModalResult)
    begin
      case AResult of
        mrYES:
          ShowMessage('You chose Yes');
        mrNo:
          ShowMessage('You chose No');
        mrCancel:
          ShowMessage('You chose Cancel');
      end;
    end);
  end;
end;