A alfonsorento Member May 10, 2015 #1 Hello, I want to put an image into a button in B4J. How can I do it?
Erel B4X founder Staff member Licensed User Longtime User May 11, 2015 #2 You can use this code to add an ImageView to a button: Code: 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: Code: 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)
A alfonsorento Member May 11, 2015 #3 Erel said: You can use this code to add an ImageView to a button: Code: 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) Click to expand... Thank you Erel. You are the best! Upvote 0
Erel said: You can use this code to add an ImageView to a button: Code: 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) Click to expand... Thank you Erel. You are the best!