Sub Class_Globals
Private Root As B4XView
Private xui As XUI
Private Label1 As B4XView
Private Timer1 As Timer
Dim CurrentDate As String
Dim CurrentTime As String
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")
Timer1.Initialize("Timer1", 1000)
Timer1.Enabled = True
DateTime.DateFormat = "EEEE, MMMM dd yyyy"
DateTime.TimeFormat = "HH:mm:ss"
CurrentDate = DateTime.Date(DateTime.Now)
CurrentTime = DateTime.Time(DateTime.Now)
End Sub
Private Sub Timer1_Tick
CurrentTime = DateTime.Time(DateTime.Now)
Dim cs As CSBuilder
cs.Initialize.Size(14).Typeface(Typeface.MONOSPACE)
cs.Color(Colors.Black)
cs.Image(LoadBitmap(File.DirAssets, "icon-calendar.jpg"), 14dip, 14dip, True).Append(" ").Append(CurrentDate).Append(" ")
cs.Image(LoadBitmap(File.DirAssets, "icon-clock.png"), 14dip, 14dip, True).Append(" ").Append(CurrentTime).Append(" ")
cs.Image(LoadBitmap(File.DirAssets, "icon-weather.png"), 14dip, 14dip, True).Append(" ").Append("30°C")
cs.PopAll
Label1.Text = cs
End Sub
Private Sub Button1_Click
Dim Yesterday As Long = DateTime.Add(DateTime.Now, 0, 0, -1)
CurrentDate = DateTime.Date(Yesterday)
End Sub
Private Sub Button2_Click
CurrentDate = DateTime.Date(DateTime.Now)
End Sub
Private Sub Button3_Click
Dim Tomorrow As Long = DateTime.Add(DateTime.Now, 0, 0, 1)
CurrentDate = DateTime.Date(Tomorrow)
End Sub