Em tempo de execução, também pode utilizar o evento: UpdateObjects:
procedure TMainForm.LIstView1UpdateObjects(const Sender: TObject; const AItem: TListViewItem);
var
URL_Foto: String;
Foto: TListItemImage;
Strm: TMemoryStream;
TmpImagem: TImage;
Http: TiDHTTP;
myThread: TThread;
begin
Foto := TListItemImage(AItem.View.FindDrawable('FOTO'));
URL_Foto := TListItemText(AItem.View.FindDrawable('URL_FOTO')).Text;
TListItemText(AItem.View.FindDrawable('URL_FOTO')).Visible := False;
if (not URL_Foto.IsEmpty ) and (Foto <> nil) and (Foto.Bitmap = nil) then
begin
URL_Foto := 'http://www.SEUDOMINIO.com.br/imagens/' + URL_Foto;
myThread := TThread.CreateAnonymousThread( procedure ()
begin
Strm := TMemoryStream.Create;
Http := TiDHTTP.Create(Self);
TmpImagem := TImage.Create(nil);
livAnuncioCaminhao.BeginUpdate;
try
Http.Get(URL_FOTO, Strm);
if (Strm.Size > 0) then
begin
Strm.Position := 0;
TThread.Synchronize(myThread, procedure ()
begin
TmpImagem.Bitmap.LoadFromStream(Strm);
Foto.OwnsBitmap := False;
Foto.Bitmap := nil;
Foto.Bitmap := TmpImagem.Bitmap;
end);;
end;
finally
Strm.Free;
Http.Free;
//Assim dá access violation
//TmpImagem.Free;
livAnuncioCaminhao.EndUpdate;
end;
end);
myThread.start();
end;
end;