Android Question [Solved] Change ImageView to B4XImageView

asales

Expert
Licensed User
Longtime User
I use the code below to load a layout - with an imageview - and create a grid of (square with same size) images in a UltimateListView, based in this example.

Now I want to change the imageview to b4ximageview, in the layout, to show different types of images (square, horizontal, vertical) in same grid, without distortions, but I get this error:
Types don't match (Warning #22)
in this line:
B4X:
Dim iv As B4XImageView = pnlLayout.GetView(0)

Original code:
B4X:
'create the layout of the image grid
Sub Cell_RowLayoutCreator(LayoutName As String, CellPanel As Panel, CellIndex As Byte)
    CellPanel.LoadLayout("cells")
End Sub

Sub Cell_RowContentFiller(RowID As Long, LayoutName As String, CellPanel As Panel, CellIndex As Byte, Position As Int)
    Try
        Dim pnlLayout As Panel = CellPanel.GetView(0)
        Dim iv As ImageView = pnlLayout.GetView(0)   '<-- change imageview to b4ximageview here

        Dim ImgIndex As Int = RowID * NB_COL + CellIndex
        
        If ImgIndex < ListaImg.Size Then
            Dim ItemString As String = ListaImg.Get(ImgIndex)
        
            Dim bmp As Bitmap
            bmp.InitializeSample(File.DirAssets, ItemString, 250dip, 250dip)

            iv.Bitmap = bmp
        Else
            iv.Bitmap = Null
        End If
    Catch
        ToastMessageShow("Error to load the list.", False)
        Log(LastException)
    End Try
End Sub

How can I change the ImageView component to B4XImageView, in this code, and create a grid of images?

Thanks in advance for any tips.
 

Alexander Stolte

Expert
Licensed User
Longtime User
B4X:
Dim iv As B4XImageView = pnlLayout.GetView(0).Tag
 
Upvote 2
Solution

asales

Expert
Licensed User
Longtime User
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…