Trying to get the text entered in an Android dialog

Trying to get the text entered in an Android dialog

I found an example for this here: https://forums.embarcadero.com/thread.jspa?messageID=862688
ASyncService.InputQueryAsync( 'How Many', ['0'], [st],
procedure (const AResult : TModalResult; const AValues : array of string)
begin
case AResult of
mrOk: st := avalues[0];
end;
end );
How do I implement a callback to capture the entered text?

Thanks...Dan'l
https://forums.embarcadero.com/thread.jspa?messageID=862688

Comments

  1. The callback is the anonymous method, and (in the lingo) you're capturing st by referring to it inside the anonymous method. What is it you're trying to do...?

    ReplyDelete
  2. Chris Rolliston I am trying to get the text that the user entered. I will then use that data (a digit) to update the text of a ListBoxItem.
    Do I need to create an event to capture the text and have it update the LBI?

    ReplyDelete
  3. OK, I figured it out. Like this:
    if TPlatformServices.Current.SupportsPlatformService (IFMXDialogServiceAsync,
    IInterface (ASyncService)) then
    begin
    ASyncService.InputQueryAsync ('How Many', ['0'], [st],
    procedure (const AResult : TModalResult; const AValues : array of string)
    begin
    case AResult of
    mrOk:
    begin
    st := avalues[0];
    lbQty.Selected.text := st;
    lstAisles.ItemIndex := lbQty.ItemIndex;
    lstAisles.Selected.TagFloat := StrToIntDef(st, 0) * lbQty.Selected.TagFloat;
    end;
    end;
    end);
    end;

    ReplyDelete

Post a Comment