iOS Question how to convert object to imageview

bagazhou

Member
Licensed User
Longtime User
HI

this code in b4i , how to can i convert object to imageview ?


B4X:
Sub SetBackgroundImage(b As Object, bmp As Bitmap, state As Int)

   If b Is Button Then
       Dim no As NativeObject = b
       no.RunMethod("setBackgroundImage:forState:", Array(bmp, state))
   End If
   
   If b Is ImageView Then
       b.Bitmap = LoadBitmap(File.DirAssets, "test.png")  //this line is error
       
   End If
   
   

End Sub
 

bagazhou

Member
Licensed User
Longtime User
I solved the problem

B4X:
Sub SetBackgroundImage(b As Object, bmp As Bitmap, state As Int)

   If b Is Button Then
       Dim no As NativeObject = b
       no.RunMethod("setBackgroundImage:forState:", Array(bmp, state))
   End If
   
   If b Is ImageView Then
       Dim img As ImageView
       img = b
       img.Bitmap = bmp
   End If
   
End Sub
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…