简体   繁体   English

Android上的Delphi Firemonkey中的模式弹出窗口

[英]Modal Popups in Delphi Firemonkey on Android

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. 我正在使用Android应用程序,但是我需要一个Popup,可以在代码中调用该Popup以创建Modal Popup,因此请在Code中设置一个Variable。 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... 我试图将其散布到不同的函数中,并且可以正常工作,但是当从一个Funktion跳转到另一个Funktion时,遵循代码变得很糟糕...

What I want to do is like the function MessageDlg() , but it is not implemented on Android. 我要执行的操作类似于MessageDlg()函数,但未在Android上实现。

I've tried the MessageDlg() with the Anonymous Function, but that also runs the code underneath befor i press a button. 我已经尝试了带匿名函数的MessageDlg() ,但是在按下按钮之前,它也运行了下面的代码。

I need something like that, but on Android the if statement will be executed befor i entered my input. 我需要类似的东西,但是在Android上,如果我输入了输入内容,就会执行if语句。

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" 我需要“点击按钮继续活动”之类的东西

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. 在这种情况下,您也不需要MyInt变量。

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;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM