B4A Library CustomGridView

This library will create a simple yet useful grid view.

Requirements:

- B4A 3.82.


How to install:

- Copy the CustomGridView.jar and CustomGridView.xml to your additional libraries directory.

Usage:
B4X:
Private grid As CustomGridView

'Initialize the library.
grid.Initialize(Activity, Me, "Grid", 3, "S")

'Prepare the CustomGridView to receive data.
grid.PrepareGridView

'Add data to the grid, it supports images from URLs or local files.
'The "Link" parameter is whatever you need the grid to return.
grid.AddToGridView("http://wac.450f.edgecastcdn.net/80450F/ultimateclassicrock.com/files/2012/06/BJ.jpg", "Bon Jovi", "Bon_Jovi")

'Show the picture titles (optional)
grid.TitleBoxVisible = True

'Display the grid.
grid.ShowGridView


NOTES:

- The grid supports up to 4 columns (if an invalid number is entered it will default to 3).

- The "cells" can be Square or Rectangular (the content will be resized).

See the attached sample for more details.

WARNING: This version will BREAK the previous one since the new one contains 1 more initialization argument.


Screenshot:

ky3eiYxl.jpg
 

Attachments

  • CustomGridView_1.5_Lib.zip
    11.2 KB · Views: 527
  • CustomGridView_Sample.zip
    35.4 KB · Views: 464
Last edited:

Mahares

Expert
Licensed User
Longtime User
@NJDude: I tried to run the sample using 3.82 . I got this error:
A referenced library is missing: imgflipmemes
Thank you for clarifying
 

Mahares

Expert
Licensed User
Longtime User
I tried to display photos in a folder in the file.DirRootExternal. The grid shows up but not the images. See my code below.
Thank you for tackling this.

B4X:
Sub Globals
    Private grid As CustomGridView   
    Dim MyImageFile, MyFolder As String    = "POC"  
    Dim FilePath As String = File.DirRootExternal & "/" & MyFolder
    Dim MyList As List           
End Sub

Sub Activity_Create(FirstTime As Boolean)
        grid.Initialize(Activity, Me, "Grid", 3)
        grid.PrepareGridView
               
        MyList.Initialize            
        MyList=File.ListFiles(FilePath)
        For i= 0 To MyList.Size-1 
            MyImageFile=MyList.Get(i)
            If MyImageFile.endswith(".jpg") Then  
                grid.AddToGridView(FilePath, MyImageFile, MyImageFile)
            End If
        Next
        grid.TitleBoxVisible = True
        grid.ShowGridView   
End Sub
 

udg

Expert
Licensed User
Longtime User
Great work, NJDude!
Just one complain: AC/DC album should come first!
And a question: can the grid be constrained to a panel on the Activity? This way I could use part of the screen for other stuff.

Umberto
 

NJDude

Expert
Licensed User
Longtime User
And a question: can the grid be constrained to a panel on the Activity? This way I could use part of the screen for other stuff.
Yes, you can add the grid to a panel.

Just one complain: AC/DC album should come first!
I'm sorry, but AC/DC should be honored to be next to the almighty Beatles.
 

AndrewKing

Member
Licensed User
Longtime User
I found that it always takes very long time to display the grid, even there is only 1 local image to display.

This is my code:

B4X:
Sub Activity_Create(FirstTime As Boolean)

ProgressDialogShow("Loading, please wait...")

grid.Initialize(Activity, Me, "Grid", 3)
grid.PrepareGridView

grid.AddToGridView("file:///android_asset/albumcover.jpg", "White Snake", "file:///android_asset/albumcover.jpg")

grid.TitleBoxVisible = True

grid.ShowGridView

If the WIFI connection is on,it will take more than 3 minitue to display the grid.

But if I disconnect the WIFI connection, it will display the grid immediatelly. (and i will see a "timeout" message right after i disconnect the WIFI)
2.png



So, my question is: does the grid library need to connect to anywhere on the internet when it starts?
 

imgsimonebiliato

Well-Known Member
Licensed User
Longtime User
Hello,
is it possibile, when clicking on a cell, enlarge the image on that cell?
 
Top