Wish [B4X] [XUI] xui.CreateLabel

Alexander Stolte

Expert
Licensed User
Longtime User
This is the way to create a XUI Label:

B4X:
Dim lbl_test as Label
lbl_test.Initialize("xlbl_test")
Dim xlbl_test as B4xView = lbl_test

with a xui.CreateLabel i can save 2 lines and a new label name.
In a bigger project this would be very usefull.

Greetings
 

Star-Dust

Expert
Licensed User
Longtime User

Erel

B4X founder
Staff member
Licensed User
Longtime User
with a xui.CreateLabel i can save 2 lines and a new label name.
In a bigger project this would be very usefull.
The reasons that XUI.CreatePanel was added are:
1. Panels are very common controls.
2. It requires a bit more code to create a cross platform panel as native panels are named Pane in B4J.

If you find yourself adding many labels programmatically then create a sub for this:
B4X:
Sub CreateLabel (Text As String) As B4XView
 Dim l As Label
 l.Initialize("") 'assuming that events not needed
 l.Text = Text
 Return l
End Sub

Usage:
B4X:
Dim lbl1 As B4XView = CreateLabel("Hello")
 
Top