Android Question Custom Grid View from SQL image (blob)

Matteo Granatiero

Active Member
Licensed User
I see this Custom Grid View Example and Library , I tried to connect through the Sql Database Cursor.Getstring but without success. For ListView I used this :
B4X:
Cursor1 = SQL1.ExecQuery2("SELECT * FROM Vestiti WHERE Categoria = ? ORDER BY rowid DESC", Array As String("T-shirts"))
For i=0 To Cursor1.RowCount-1
    
        Cursor1.Position=i
        
        Dim Buffer() As Byte
        Buffer = Cursor1.GetBlob("Immagine")
        Dim InputStream1 As InputStream
        InputStream1.InitializeFromBytesArray(Buffer, 0, Buffer.Length)
        Dim Bitmap1 As Bitmap
        Bitmap1.Initialize2(InputStream1)
        InputStream1.Close
        
        ListView1.AddTwoLinesAndBitmap(Cursor1.GetString("Identificativo"),"",Bitmap1)
        
        Next
 

mangojack

Well-Known Member
Licensed User
Longtime User
I tried to connect through the Sql Database Cursor.Getstring but without success


You encountered an Error ? ... What was the error message? ... How is this problem related to CustomGridView ?

Cursor1.GetString("Identificativo") result was empty ? ... We need more information.


On a side note ... better to use ResultSet (And xCustomListView instead of ListView)
B4X:
Dim rs As ResultSet = SQL1.ExecQuery2("SELECT * FROM Vestiti WHERE Categoria = ? ORDER BY rowid DESC", Array As String("T-shirts"))
Do While rs.NextRow
    Dim Buffer() As Byte = rs.GetBlob("Immagine")
    '............

    ListView1.AddTwoLinesAndBitmap(rs.GetString("Identificativo"),"",Bitmap1)
Loop
 
Last edited:
Upvote 0

Matteo Granatiero

Active Member
Licensed User
You encountered an Error ? ... What was the error message? ... How is this problem related to CustomGridView ?

Cursor1.GetString("Identificativo") result was empty ? ... We need more information.


On a side note ... better to use ResultSet (And xCustomListView instead of ListView)
B4X:
Dim rs As ResultSet = SQL1.ExecQuery2("SELECT * FROM Vestiti WHERE Categoria = ? ORDER BY rowid DESC", Array As String("T-shirts"))
Do While rs.NextRow
    Dim Buffer() As Byte = rs.GetBlob("Immagine")
    '............

    ListView1.AddTwoLinesAndBitmap(rs.GetString("Identificativo"),"",Bitmap1)
Loop
the error is that the grid.add only accepts URLs and I should load a Bitmap taken from the SQL Blob
 
Upvote 0

mangojack

Well-Known Member
Licensed User
Longtime User
Maybe try this ..

Or this ...
 
Upvote 0
Top