Sub Class_Globals
Private Root As B4XView
Private xui As XUI
Type Player (name As String, count As Int)
End Sub
Public Sub Initialize
' B4XPages.GetManager.LogEvents = True
End Sub
'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
Root.LoadLayout("MainPage")
Dim players As List
players.Initialize
players.Add(CreatePlayer("Player 1",122)) ' Add Player to the list
players.Add(CreatePlayer("Player 2",78))' Add Player to the list
players.Add(CreatePlayer("Player 3",142))' Add Player to the list
players.Add(CreatePlayer("Player 4",67))' Add Player to the list
players.Add(CreatePlayer("Player 5",43))' Add Player to the list
players.Add(CreatePlayer("Player 6",156))' Add Player to the list
players.Add(CreatePlayer("Player 7",77))' Add Player to the list
players.Add(CreatePlayer("Player 8",11))' Add Player to the list
players.SortType("count",False) ' Sorts the list by "count" DESC of the Customtype
Log(players) ' Log all Players
Dim p1 As Player = players.Get(0) ' Get the topmost Player
Log($"Player ${p1.name}: ${p1.count} Points"$) ' LOGS Player Player 6: 156 Points
End Sub
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
Private Sub Button1_Click
xui.MsgboxAsync("Hello world!", "B4X")
End Sub
Public Sub CreatePlayer (name As String, count As Int) As Player
Dim t1 As Player
t1.Initialize
t1.name = name
t1.count = count
Return t1