Android image gallery lazarus / 43-Android ---------------------------------------------------------------------- xinyiman · 2019-11-06 14:08 Hi guys, can anyone tell me where to find an example to create a gallery of images? Let me explain: I have to show the thumbnails of the images belonging to the user in a screen So that then clicking on the thumbnail opens a full screen image. The full screen image I know how to do it, but the thumbnail list doesn't? Obviously I could have many thumbnails and have to scroll down to see them all. ---------------------------------------------------------------------- wp · 2019-11-06 15:45 I've answered a similar question recently: https://forum.lazarus.freep ascal.org/index.php/topic,47113.msg336746.html#msg336746 ---------------------------------------------------------------------- xinyiman · 2019-11-07 13:14 Hi wp, thanks for the reply, but it's not the same thing. I know how to do it with lazarus for pc, the problem is for android. ---------------------------------------------------------------------- wp · 2019-11-07 14:11 Excuse me. I see now that you posted your question in the Android board and you provided all information required. But I normally look for new posts only in the "Recent" bar at the right, and there's nothing which gives me this kind of information. You could simply classification of your question if you'd mention "Android" also in the title, e.g. "Image Gallery for Android" ---------------------------------------------------------------------- jmpessoa · 2019-11-07 22:49 Hi, xinyiman! At the moment, you can try the: GetResizedBitmap(....)     from  jBitmap component.... [edited] you can try jViewFlipper component, too: Adjust it to a "thumbnails"  size  and  try: jViewFlipper1. AddView(.....) ---------------------------------------------------------------------- xinyiman · 2019-11-08 10:17 Hi jmpessoa, thanks for the reply. Using GetResizedBitmap I can resize the image. But I can't get the components to display at run time. I created a small function, which does not go wrong, but does not show anything on the screen. Can you tell me what's wrong? For global declaration Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i type   { TAndroidModule1 }   TAndroidModule1 = class(jForm)    jButton1: jButton;    jImageList1: jImageList;    jScrollView1: jScrollView;    jSpinner1: jSpinner;    procedure jButton1Click(Sender: TObject);  private    {private declarations}    GalleryImages : array of jImageView;    GalleryBmp    : array of jBitmap;    procedure CreateGallery;    procedure ClickMiniatura(Sender: TObject);  public  {public declarations}  end;       My procedure to create a runtime the image gallery Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TAndroidModule1.CreateGallery;var   i             : integer;   //top         : integer;   //left          : integer;   num_col       : integer;   space_col     : integer;begin     num_col   := 3;     space_col := 4;     //top       := 0;     //left      := 0;      for i := 0 to Length(GalleryBmp)-1 do     begin          GalleryBmp[i].Free;          GalleryBmp[i] := nil;           GalleryImages[i].Free;          GalleryImages[i] := nil;     end;      SetLength(GalleryBmp,0);     SetLength(GalleryImages,0);      for i:=0 to Self.jImageList1.Count-1 do     begin          SetLength(GalleryBmp, Length(GalleryBmp)+1);          GalleryBmp[Length(GalleryBmp)-1]                  := jBitmap.Create(Self);          GalleryBmp[Length(GalleryBmp)-1].Name           := 'jBitmap' + IntToStr(i+1);          GalleryBmp[Length(GalleryBmp)-1].Images           := Self.jImageList1;          GalleryBmp[Length(GalleryBmp)-1].ImageIndex       := i;            SetLength(GalleryImages, Length(GalleryImages)+1);          GalleryImages[Length(GalleryImages)-1]                := jImageView.Create(Self.jScrollView1);          GalleryImages[Length(GalleryImages)-1].Name           := 'jImageView' + IntToStr(i+1);          GalleryImages[Length(GalleryImages)-1].Parent         := Self.jScrollView1;          //GalleryImages[Length(GalleryImages)-1].Top            := top;        //GalleryImages[Length(GalleryImages)-1].Left           := left;         if i > 0 then          begin               GalleryImages[Length(GalleryImages)-1].Anchor              := GalleryImages[Length(GalleryImages)-2];                if ((i mod num_col) = 0) and (i>0) then               begin                    GalleryImages[Length(GalleryImages)-1].PosRelativeToAnchor := [raBelow];                    GalleryImages[Length(GalleryImages)-1].PosRelativeToParent :=[rpLeft];               end else begin                    GalleryImages[Length(GalleryImages)-1].PosRelativeToAnchor := [raAlignBaseLine];               end;          end else begin             GalleryImages[Length(GalleryImages)-1].PosRelativeToParent :=[rpTop, rpLeft];          end;            GalleryImages[Length(GalleryImages)-1].Width          := Trunc(Self.jScrollView1.Width / num_col);          GalleryImages[Length(GalleryImages)-1].Height         := GalleryImages[Length(GalleryImages)-1].Width;           GalleryImages[Length(GalleryImages)-1].ImageScaleType := scaleCenter;          GalleryImages[Length(GalleryImages)-1].Enabled        := true;          GalleryImages[Length(GalleryImages)-1].Visible        := true;           //GalleryImages[Length(GalleryImages)-1].Tag          := i;          //GalleryImages[Length(GalleryImages)-1].OnClick      := ClickMiniatura;           GalleryImages[Length(GalleryImages)- 1].SetImageBitmap(GalleryBmp[Length(GalleryBmp)- 1].GetResizedBitmap(GalleryImages[Length(GalleryImages)-1].Width, GalleryImages[Length(GalleryImages)-1].Height));           GalleryImages[Length(GalleryImages)-1].Refresh;          GalleryImages[Length(GalleryImages)-1].Invalidate;           {if ((i mod num_col) = 0) and (i>0) then          begin               left := 0;               top  := top + GalleryImages[Length(GalleryImages)-1].Height + space_col;          end else begin               left := left + GalleryImages[Length(GalleryImages)-1].Width + space_col;          end;}      end;      Self.jScrollView1.Invalidate;end; ---------------------------------------------------------------------- jmpessoa · 2019-11-09 16:30 You can try: GalleryBmp[Length(GalleryBmp)-1]:= jBitmap.Create(Self); GalleryBmp[Length(GalleryBmp)-1].Init(gApp);     //or after some configs.....??? GalleryImages[Length(GalleryImages)-1]:= jImageView.Create(Self);  //try "self" here .... GalleryImages[Length(GalleryImages)-1].Init(gApp)  ////or after some configs.....??? Good news! I am doing a new demo to help your! ---------------------------------------------------------------------- jmpessoa · 2019-11-11 04:43 Hi, xinyiman! You  can try new demo  [GUI]   "AppScrollingImages" [update your LAMW from github!] Thank you! ---------------------------------------------------------------------- xinyiman · 2019-11-11 07:06 Hi, thank you very much. Today I try it and let you know. ---------------------------------------------------------------------- xinyiman · 2019-11-12 07:52 Your demo run correctly. Thank you very much