B4A Class [B4X] lmB4XDateTemplate

[It's crossplatform, like the original, of course]

I needed a "date picker" that shows "full" days, days for which I have data in a DB.

So I modified the official B4XDateTemplate.
I'm still modifying it; when it will be "completed", I will publish it, also attaching an example with a very small test DB.

Note that a DB is not necessary, you just have to pass a list of Int, the days to highlight for the month and year shown.

I will calmly provide the possibility to switch between dark and light theme, although you can change all the colors you want.

One thing that I consider "important", even if what I needed was the highlighting of some days, is that I removed the 3 labels for the year selection that I replaced with a B4XPlusMinus.
It is very useful, because with the labels you need to do many clicks to change the year (I'm only thinking about it now: probably I could have implemented the long click on the two labels, + and -).
For now I have the problem that I could not make the B4XPlusMinus look the same as the original B4XDateTemplate, that is, like the one for the month selection.

You can choose whether to highlight the selected days with a circle or a rectangle.
You can also choose whether all days will be clickable or only the highlighted ones.


java_bly3TK8d7g.gif
 
Last edited:

LucaMs

Expert
Licensed User
Longtime User
Ok, it seems to work.

You will use the official B4XDialog (it is part of the Xui Views library) and its ShowTemplate method but, as you can see in the project I attach, you will add and use this class, lmB4XDateTemplate, add and use also the layout file DateTemplate2.

I repeat that the purpose is to be able to highlight N days of the month (and, at your choice, make only them clickable or all days).
You can choose whether to highlight the days with circles or rectangles.

Obviously, it is not necessary to "associate" a DB to the dialog-template, you will pass a list of numbers, the days of the displayed month to highlight (see how in the project).
Yet I believe that this is precisely the case in which the class is most useful, with a DB table. In the attached project, the example is really minimal: some (few) days are "associated" with a record of a table, which contains only a date and a note. By clicking on a highlighted day, the relative note will be taken from the DB and displayed in a MsgboxAsync.
Since this is just a demonstration of the use of this class, I have not added code for editing, deleting and creating a note.

I do not have Apple HW, so not even B4i and I could not create the layout for this platform, but for you it will be a breeze, you just need to open one of the other two IDEs, the layout, copy the views and paste them into the B4i Designer.

Finally, do not forget to offer me a coffee ☕, otherwise how could I stay awake at this hour (about 3:37 AM)? 😊

java_yQSpoKgMbr.gif


java_K1scTAXLLu.gif



[Erel, if you want to use this class and the ayout instead of your originals, not only can you do it but I would be very happy (and it would be very convenient).
Note that for the month and year selection I used two B4XPlusMinus, eliminating the 6 views that served this purpose].
 

Attachments

  • lmB4XDateTemplate_Test.zip
    18.6 KB · Views: 6
Last edited:
Top