B4J Question Button with image

Erel

B4X founder
Staff member
Licensed User
Longtime User
You can use this code to add an ImageView to a button:
B4X:
Sub SetGraphic(Btn As Button, Graphic As Node)
   Dim jo As JavaObject = Btn
   jo.RunMethod("setGraphic", Array(Graphic))
End Sub

Dim iv As ImageView
iv.Initialize("")
iv.SetImage(fx.LoadImage(File.DirAssets, "EffectNone.png"))
SetGraphic(button1, iv)
 
Upvote 0
You can use this code to add an ImageView to a button:
B4X:
Sub SetGraphic(Btn As Button, Graphic As Node)
   Dim jo As JavaObject = Btn
   jo.RunMethod("setGraphic", Array(Graphic))
End Sub

Dim iv As ImageView
iv.Initialize("")
iv.SetImage(fx.LoadImage(File.DirAssets, "EffectNone.png"))
SetGraphic(button1, iv)
Thank you Erel. You are the best!
 
Upvote 0
Top