Listviewresim yolu

FireMonkey ve Mobil uygulama (iOS, Android, Windows Phone) ile ilgili sorularınızı bu foruma sorabilirsiniz.
Cevapla
Kullanıcı avatarı
Serhat
Üye
Mesajlar: 203
Kayıt: 27 Tem 2014 11:10

Listviewresim yolu

Mesaj gönderen Serhat »

Selam;


Listview de imagelist deki resimleri gösteriyorum, acaba bilgisayarda bulunan resim yolunu vererek (Data['Image'] := 'C:\Users\Solo\Kitaplıklar\Resimler\İcon\32x32 right.png';) lisview de bu resimleri nasıl göstere bilirim?
Kullanıcı avatarı
AliZairov
Üye
Mesajlar: 341
Kayıt: 06 Nis 2012 03:09
Konum: Azerbaycan, Bakü
İletişim:

Re: Listviewresim yolu

Mesaj gönderen AliZairov »

Merhaba. Ben netden indiriyordum asenkron bir şekilde kasmadan. Bu kod parçası düzenleyerek projenize uygun hale getirerek kullana bilirsiniz.

Kod: Tümünü seç

  procedure setLogo(ListView: TListView; code, url: string; id: Integer);
  var
    Cache: string;
    T: TThread;
  begin
    Cache := TPath.GetCachePath + '/AzerBoxPlus/Cache/';
    if not TFile.Exists(Cache + code + '.png') then
    begin
      T := TThread.CreateAnonymousThread(
      procedure
      var
        HTTP: TIdHTTP;
        MS: TMemoryStream;
      begin
        MS := TMemoryStream.Create;
        HTTP := TIdHTTP.Create(nil);
        try
          try
            HTTP.Get(url, MS);
            TThread.Synchronize(TThread.CurrentThread,
              procedure()
              begin
                ListView.Items[id].Bitmap.LoadFromStream(MS);
                MS.SaveToFile(Cache + code + '.png');
              end);
          except
            MS.Free;
          end;
        finally
          HTTP.Free;
        end;
      end);
      T.start;
    end else
    begin
      T := TThread.CreateAnonymousThread(
      procedure
      begin
        TThread.Synchronize(TThread.CurrentThread,
        procedure()
        begin
          ListView.Items[id].Bitmap.LoadFromFile(Cache + code + '.png');
        end);
      end);
      T.start;
    end;
  end;
Kullanımı:

Kod: Tümünü seç

setLogo(ListView, 'dosya ismi', 'url', index);
Cevapla