B4J Question Button with image

Discussion in 'B4J Questions' started by alfonsorento, May 10, 2015.

  1. alfonsorento

    alfonsorento Member

    Hello,
    I want to put an image into a button in B4J.
    How can I do it?
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    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)
     
    BeneBarros likes this.
  3. alfonsorento

    alfonsorento Member

    Thank you Erel. You are the best!
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice