Sub NewButton(Text As String, TextSize As Int, TextFont As Font, Event As String) As Button
Dim btn As Button
btn.Initialize(Event, btn.STYLE_SYSTEM)
btn.SetBorder(1, Colors.Black, 3)
btn.CustomLabel.Font = Font.CreateNew(TextSize)
btn.Text = Text
Return btn
End Sub
Sub NewButton(Text As String, TextSize As Int, TextFont As Font, Event As String) As Button
Dim btn As Button
btn.Initialize(Event, btn.STYLE_SYSTEM)
btn.SetBorder(1, Colors.Black, 3)
btn.CustomLabel.Font = Font.CreateNew(TextSize)
btn.CustomLabel.TextColor = Colors.Green
btn.Color = Colors.Red
btn.Text = Text
Return btn
End Sub
The property is read-only. The label itself is not read-only.
There are two ways to set the color used in the "pressed state":
1. With the designer:
2. With NativeObject:
B4X:
'state: 0 = normal, 1 = pressed, 2 = disabled
Sub SetButtonTextColor(btn As Button, clr As Int, state As Int)
Dim no As NativeObject = btn
no.RunMethod("setTitleColor:forState:", Array(no.ColorToUIColor(clr), state))
End Sub
SetButtonTextColor(Button1, Colors.Grean, 1)