B4J Question B4XPlusMinus and Time

Elric

Active Member
Licensed User
I'm trying to implement time in a B4XPlusMinus, like this:
1622490178412.png

hours and minutes together.

I looked for setting SetNumericRange but without success. So, I used a workaround:

B4X:
    Private TimeList As List
    (...)
    TimeList.Initialize
    For j = 0 To 23
        For k = 0 To 59
            TimeList.Add($"$1.0{j}:$2.0{k}"$)
        Next
    Next
    (...)
    B4XPlusMinus1.SetStringItems(TimeList)
that works perfectly. But this sound to me as smelling code.

I wonder if there is a way with SetNumericRange or another way that doesn't involve two For cycle and a list.
 

William Lancee

Well-Known Member
Licensed User
Time is of course a continuum. Numeric range of Time of day is 0 to 1439 minutes. But B4XFormatter can't convert minutes to hours and mins.
So your approach seems OK to me. Remember that if you make TimeList a global it only needs to be done once in the whole App and execution time is negligible.
 
Upvote 0
Top