Android Question Load an Image from MS Sql Server into customlistview

SoftSpot

New Member
Licensed User
I am having trouble loading an image (sql type: image) into my customlistview. Without the Image code all works fine, I would appreciate some here as I an running into walls.


B4X:
#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
    Dim xui As XUI
    Type ItemValue (bmp As Bitmap,lbl As Label)
    
    
End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.

    Private lsvOpp As CustomListView
    
    Private ImageView1 As B4XView
    Private lblName As B4XView
    
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("frmOperators")
    
    
    Dim rsOp As JdbcResultSet
        
    rsOp = modDB.Sql1.ExecQuery ("select name,surname,grid,img from Operator where grid > 0 order by name")
    
    Do While rsOp.NextRow
        
            
        '**********************
        Dim p As B4XView = xui.CreatePanel("")
        p.SetLayoutAnimated(0,0,0,100%x,120dip)
        p.LoadLayout("listOps")
        
        lblName.Text = rsOp.GetString("name").Trim
        
        'to load the image
        Dim Buffer() As Byte
        If rsOp.GetBlob("img") <> Null Then
            Buffer = rsOp.GetBlob("img")
            Dim InputStream1 As InputStream
            InputStream1.InitializeFromBytesArray(Buffer, 0, Buffer.Length)
            Dim bmp As Bitmap
            bmp.Initialize2(InputStream1)
            InputStream1.Close
        End If
        
        lsvOpp.Add(p,"")
    Loop
    

End Sub


Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub
 

Attachments

  • CLV1.PNG
    CLV1.PNG
    52.9 KB · Views: 267
  • CLV2.PNG
    CLV2.PNG
    45.7 KB · Views: 261

SoftSpot

New Member
Licensed User
Thanks Erel, this is my first project, trying to put things together, but definitely not the last. Will have a look at B4XPages.
 
Upvote 0
Top