iOS Question LoadBitmap

ciginfo

Well-Known Member
Licensed User
Hello
I want to load alternately different images into a Image View
If i code, it works
B4X:
ImageView1.Bitmap = LoadBitmap(File.DirAssets, "MyImage.png")
But if I code
B4X:
Dim Chemin as string
Chemin = "LoadBitmap(File.DirAssets, 'MyImage.png')"
ImageView1.Bitmap = Chemin
It does not work. Is Chemin as string correct?

Thank you
 

klaus

Expert
Licensed User
Is Chemin as string correct?
No !
LoadBitmap is a method ! You cannot replace it by a string.
What you can do, if you want to use variables, is:
B4X:
Dim Repertoire = File.DirAssets As String
Dim Fichier1 = "MyImage.png"
'
'
ImageView1.Bitmap = LoadBitmap(Repertoire , Fichier1)
 
Last edited:

ciginfo

Well-Known Member
Licensed User
OK, thank you, and that this code can run with a customListView ClVActus?
B4X:
Sub CreateListItem3(Text1 As String, Text2 As String, Vignette As String, Width As Int, Height As Int) As Panel
   
    Dim p As Panel
    p.Initialize(""
    Dim lbl1, lbl2 As Label
   
    lbl1.Initialize("lbl1")
    lbl1.Text = Text
   
    lbl2.Initialize("lbl2"
    lbl2.Text = Text2
  
    Dim ImgVignette As ImageView
    ImgVignette.Initialize("ImgVignette")
    Dim Repertoire = "File.DirAssets" As String
    ImgVignette.Bitmap = LoadBitmap(Repertoire , Vignette)
   
    p.AddView(ImgVignette, 2dip, 2dip, 25%x, 25%x )
    p.AddView(lbl1, 5dip + 25%x, 0dip, 75%x, Height/2 ) 
    p.AddView(lbl2, 5dip + 25%x, Height/2, 75%x, Height/2)
    Return p
End Sub

Private Sub Application_Start (Nav As NavigationController)
    NavControl = Nav

    TabControl.Initialize("TabControl")
    ' Initialize Actus and load a layout file
    Actus.Initialize("Actus")
    Actus.RootPanel.LoadLayout("Actus")
    
    clvActus.Initialize(Me, "clvActus", 100%x)'CustomListView
    Actus.RootPanel.AddView(clvActus.AsView, 0, 5%y, 100%x, 72%y)

     For i = 0 To 10 
                   
                    Dim MyVignette = "MyImage.png"
                    Dim Nom = "MyName"
                     Dim ouverture = ""Myouverture"
                     clvActus.Add(CreateListItem3(Nom, Ouverture, MyVignette, clvActus.AsView.Width, 50dip), 70dip, M)
  next
End sub
 
Top