Sub Class_Globals
Private Root As B4XView
Private xui As XUI
Private Timer1 As Timer
Private StartTime As Long
End Sub
Public Sub Initialize
End Sub
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
Root.LoadLayout("MainPage")
Timer1.Initialize("Timer1", 500)
End Sub
Private Sub Timer1_Tick
Dim milliseconds As Long = DateTime.Now - StartTime
B4XPages.SetTitle(Me, ConvertMillisecondsToString(milliseconds))
End Sub
Private Sub Button1_Click
If Timer1.Enabled = False Then
StartTime = DateTime.Now
Timer1.Enabled = True
Else
Timer1.Enabled = False
End If
End Sub
'https://www.b4x.com/android/forum/threads/b4x-convert-milliseconds-to-string.89851/#content
Private Sub ConvertMillisecondsToString(t As Long) As String
Dim hours, minutes, seconds As Int
hours = t / DateTime.TicksPerHour
minutes = (t Mod DateTime.TicksPerHour) / DateTime.TicksPerMinute
seconds = (t Mod DateTime.TicksPerMinute) / DateTime.TicksPerSecond
Return $"$1.0{hours}:$2.0{minutes}:$2.0{seconds}"$
End Sub