Modal Popups in Delphi Firemonkey on Android

Viewed 514

I am working on an Android Application, but I need a Popup, which I can call in code to create a Modal Popup, so set a Variable in Code. I tried to spread it around different functions, and it worked, but its getting quite bad to follow the code, when jumping from one Funktion to another...

What I want to do is like the function MessageDlg(), but it is not implemented on Android.

I've tried the MessageDlg() with the Anonymous Function, but that also runs the code underneath befor i press a button.

I need something like that, but on Android the if statement will be executed befor i entered my input.

MyInt: Integer;
begin

  MessageDlg('You want to Continue?', System.UITypes.TMsgDlgType.mtInformation,
  [System.UITypes.TMsgDlgBtn.mbYes, System.UITypes.TMsgDlgBtn.mbNo], 0,
  procedure(const AResult: TModalResult) begin
    case AResult of
      mrYes:
        MyInt := 0;
      mrNo:
        MyInt := 1;
    end;
  end);

  if MyInt = 0 then
    //Do Something
  else
    //Do Something
end;

I need it for something like "Click a button to Continue event"

1 Answers

You have to move your logic into anonymous method. That will be executed after user clicks appropriate button. You also don't need MyInt variable in that case.

begin

  MessageDlg('You want to Continue?', System.UITypes.TMsgDlgType.mtInformation,
  [System.UITypes.TMsgDlgBtn.mbYes, System.UITypes.TMsgDlgBtn.mbNo], 0,
  procedure(const AResult: TModalResult) begin
    case AResult of
      mrYes:
        begin
          //Do Something (MyInt = 0 branch)
        end;
      mrNo:
        begin
          //Do Something (MyInt = 1 branch)
        end;
    end;
  end);

end;
Related