#Region Project Attributes
#ApplicationLabel: B4A Example
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
Private xui as XUI
End Sub
Sub Globals
Private button1 As Button
Private imgStatus As Bitmap
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Layout")
' Load the status image
imgStatus = LoadBitmap(File.DirAssets, "setting.png")
UpdateButtonStatus(button1, imgStatus)
End Sub
Sub UpdateButtonStatus(btn As Button, img As Bitmap)
' Create a Canvas to draw on the button
Dim cvs As Canvas
cvs.Initialize(btn)
' Calculate the position for the status image (top right corner)
Dim imgSize As Int = 24dip ' Size of the status image
Dim left As Int = btn.Width - imgSize - 5dip ' 5dip padding from the right edge
Dim top As Int = 5dip ' 5dip padding from the top edge
' Draw the status image
Dim Rect As Rect
Rect.Initialize(left, top, left + imgSize, top + imgSize)
cvs.DrawBitmap(img, Null, Rect)
Activity.Invalidate
End Sub
Private Sub Activity_LongClick
button1.Enabled= Not(button1.Enabled)
' Update the button to show the status icon
If button1.Enabled =True Then
UpdateButtonStatus(button1, imgStatus)
Else
UpdateButtonStatus(button1, imgStatus)
End If
End Sub
Private Sub Button1_Click
xui.MsgboxAsync("clicked","clicked")
End Sub