how do i work with showmodal in FMX?

≯℡__Kan透↙ 提交于 2019-12-04 06:08:26

问题


i am trying to create a login form to my main android form, so i do something like this

var
  CanGo: Boolean;

begin
  Application.Initialize;
  Application.CreateForm(TForm1, Form1);
  loginfrm := Tloginfrm.Create(nil);
    try
    loginfrm.ShowModal;
    CanGo := loginfrm.LoginSuccess = true;
  finally
    FreeAndNil(loginfrm);
  end;
  if CanGo then
  Application.Run;
end.

i been doing this in win32 application and its working just fine , when i try to do the same way on android application stopped on touchscreen and wont show login form , is Show modal is different on android ? what iam doing wrong ?


回答1:


There are lots of similar questions here on SO. Read the documentation:

FMX.Forms.TCommonCustomForm.ShowModal

Caution: Modal dialog boxes are not supported in Android apps. Instead of calling ShowModal, you should call Show, and have the form return and call your event. We recommend do not use modal dialog boxes on either of the mobile platforms (iOS and Android) because unexpected behavior can result. Avoiding usage of modal dialog boxes eliminates potential problems in debugging and supporting your mobile apps.

There have been different ways to call ShowModal proposed by Embarcadero since the mobile platforms were introduced. All of them had flaws, and now docs tells you not to use them at all.



来源:https://stackoverflow.com/questions/33609526/how-do-i-work-with-showmodal-in-fmx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!