I'm making an Android app using Firemonkey, I took an example from Embarcadeiro but when I run the search several times, I call the procedure to perform the search, I go back to the screen and call again, the app closes alone. I'm showing the search on components in a frame.
Here is the code I'm using.
var
Item: TListBoxItem;
begin
fgActivityDialog1.Title := 'Carregando Lotes';
fgActivityDialog1.Message := 'Aguarde.';
fgActivityDialog1.Show;
DM.qryNotas.Active := false;
DM.qryNotas.SQL.Text := _Select + vStatus;
DM.qryNotas.Active := true;
FrameNotas.ListBox1.BeginUpdate;
FrameNotas.ListBox1.Items.Clear;
try
DM.qryNotas.First;
while not DM.qryNotas.Eof do begin
Item := TListBoxItem.Create(FrameNotas.ListBox1);
Item.Parent := FrameNotas.ListBox1;
Item.ClipChildren := True;
Item.StyleLookup := 'LayoutNotas';
Item.Height := 170;
Item.Tag := DM.qryNotasNUMERO_NOTA.AsInteger;
if DM.qryNotasSTATUS_ENTREGA.AsString = 'N' then
Item.StylesData['imgStatus'] := rctVermelho.Fill.Bitmap.Bitmap;
if DM.qryNotasSTATUS_ENTREGA.AsString = 'I' then
Item.StylesData['imgStatus'] := rctVerde.Fill.Bitmap.Bitmap;
if DM.qryNotasSTATUS_ENTREGA.AsString = 'F' then
Item.StylesData['imgStatus'] := rctAzul.Fill.Bitmap.Bitmap;
Item.StylesData['img.hittest'] := False ;
Item.StylesData['NomeFantasia'] := DM.qryNotasNOME_FANTASIA.AsString;
Item.StylesData['lblNumeroNota'] := DM.qryNotasNUMERO_NOTA.AsString;
Item.StylesData['lblLote'] := DM.qryNotasNUMERO_LOTE.AsString;
Item.StylesData['lblVendedor'] := DM.qryNotasNOME_VENDEDOR.AsString;
Item.StylesData['lblDataEmissao'] := DM.qryNotasDATA_EMISSAO.AsString;
Item.StylesData['lblDataSaida'] := DM.qryNotasDATA_SAIDA.AsString;
Item.StylesData['lblEndereco'] := DM.qryNotasENDERECO.AsString +
', ' + DM.qryNotasNUMERO.AsString;
Item.StylesData['lblBairro'] := DM.qryNotasBAIRRO.AsString;
Item.StylesData['lblCidade'] := DM.qryNotasCIDADE.AsString;
Item.StylesData['lblTelefone'] := DM.qryNotasTELEFONE.AsString;
DM.qryNotas.Next;
end;
finally
FrameNotas.ListBox1.EndUpdate;
FreeAndNil(Item);
end;