' --- 1. Declare the component in Sub Class_Globals ---
Private btnPlay As B4XDaisyIconButton
' --- 2. Initialize and configure in B4XPage_Created ---
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
' Initialize with the current module (Me) and the event prefix ("btnPlay")
btnPlay.Initialize(Me, "btnPlay")
' Create the actual View object (e.g., 56dip for an XL button)
Dim btnView As B4XView = btnPlay.CreateView(56dip)
Root.AddView(btnView, 50dip, 50dip, 56dip, 56dip) ' Add to layout
' Set up the properties programmatically
btnPlay.setIconAsset("play.svg") ' Set your SVG icon
btnPlay.setVariant("primary") ' Apply the 'primary' color variant
btnPlay.setStyle("solid") ' Use a solid background
btnPlay.setShape("circle") ' Make it perfectly round
btnPlay.setSize("xl") ' Extra large size
' Optional: Add a custom payload to the button's tag
btnPlay.setTag("PlayMusic")
End Sub
' --- 3. Trap the Click Event! ---
' The event signature passes the 'Tag' as an Object payload
Private Sub btnPlay_Click (Tag As Object)
Log("Button Clicked! Payload: " & Tag)
' Example: Show loading state while processing
btnPlay.setLoading(True)
' Simulate a network request or heavy task...
Sleep(2000)
' Stop loading state once done
btnPlay.setLoading(False)
End Sub