Cursussen/Courses Codesnippets     Top 
B4A-calendar - Date events


Date events
It would be nice if you could tap on a day number and you could do something with that selected date.
For that to work you need an event handler.
In B4A when you initialize a view you can give it an EventName (a string). Remember the image from before…
Lets name it “lblday” and provide a subroutine to handle the event:
Public Sub lblday_Click
	Dim l As Label
	l = Sender
	Log(l.Tag)	' date ticks value
End Sub
Change the arguments from the subroutine set_label and add a tag argument.
private Sub set_label(lbltext As String, intbackground As Int, lbltag As String) As Label
	Private lbl As Label
	lbl.Initialize(lbltag)
Change the calls to set_label and add the “lblday” tag for the labels with a day number.
Add a line to fill the tag with the date ticks from the date.
lbl.Tag = DateUtils.SetDate(yr,mnth,daynumber)
daynumber = daynumber + 1
Now you can check the logs for the date ticks value.
The first of May 2022 shows the following ticks value: 1651338000000
So now you have a calendar with a selection subroutine.
In the lblday_Click subroutine you can call another B4XPage for instance to maintain notes for each selected date.


X

Paragraphs

Date events