Android Question How I can make a Swift Button with an image on it?

ptraian2

New Member
Hello at all.
I want to make an button with an image when this is pressed and with another image when is released and I want this button will have a functionality like an Swift Button.
(when is pressed I can do something and when this is released I can do another thing)
Thanks for your support!
 

TILogistic

Expert
Licensed User
Longtime User
test:
demo for icon fonts and image file (commented).
1641192815511.png


EDIT add code (vSwiftButton.Update)
B4X:
Public Sub SetSwiftButton(vSwiftButton As SwiftButton, Status As String)
    Dim cImage As Char, sText As String
'    Dim xImage As B4XBitmap
   
    Select Status
        Case 1
'            xImage = xui.LoadBitmap(File.DirAssets, "iconup.png")
            cImage = Chr(0xF01B)
            sText = "Status ButtonUp"
        Case 2
'            xImage = xui.LoadBitmap(File.DirAssets, "icondown.png")
            cImage = Chr(0xF01A)
            sText = "Status ButtonDown"
        Case Else
            Return
    End Select

    'image
'    Dim cs As CSBuilder
'    cs.Initialize
'    cs.Image(xImage, 50dip, 50dip, False)
'    cs.Append(CRLF)
'    cs.TypeFace(Typeface.DEFAULT)
'    cs.Size(14)
'    cs.Color(xui.Color_Black)
'    cs.Bold
'    cs.VerticalAlign(4dip)
'    cs.Append(sText)
'    cs.PopAll
   
   
    Dim cs As CSBuilder
    cs.Initialize
    cs.Size(60)
    cs.Alignment("ALIGN_CENTER")
    cs.Color(xui.Color_Blue)
    cs.TypeFace(Typeface.FONTAWESOME)
    cs.Append(cImage)
    cs.Append(CRLF)
    cs.TypeFace(Typeface.DEFAULT)
    cs.Size(14)
    cs.Color(xui.Color_DarkGray)
    cs.Bold
    cs.VerticalAlign(4dip)
    cs.Append(sText)
    cs.PopAll
   
    vSwiftButton.SetColors(xui.Color_Yellow, xui.Color_Black)
    vSwiftButton.SideHeight = 10dip
    vSwiftButton.xLBL.Text = cs
    vSwiftButton.Update
End Sub
 

Attachments

  • TEST-VIEWS.zip
    10.4 KB · Views: 107
Last edited:
Upvote 0
Top