B4A Library [B4X] [XUI] AS TimePicker

This is a simple TimePicker, with android style.

I spend a lot of time in creating views, like this and to create a high quality view cost a lot of time. If you want to support me and further views, then you can do it here by Paypal or with a coffee. :)

Animation.gif
MinuteSteps.gif
12h Format.gif

Events
  • SelectedHourChanged and SelectedMinuteChanged
    • This event is triggered every time the pointer moves
  • SelectedHour and SelectedMinute
    • This event is triggered when you release the pointer
  • SelectionDone
    • This event is triggered when an hour and minute is selected
Designer Properties
  • AutoSwitch
    • If True then automatically switches to minutes when the user releases the clock during hour selection
  • MinuteSteps
    • Indicates in how many steps the selector can be moved
    • Example: 5 = the pointer only moves in 5 minute increments
  • TimeFormat
    • If 24h then 2 rows are displayed
    • If 12h just 1 row are visible
1697292707394.png

ASTimePicker
Author: Alexander Stolte
Version: 1.00

  • AS_TimerPicker
    • Events:
      • SelectedHour (Hour As Int)
      • SelectedHourChanged (Hour As Int)
      • SelectedMinute (Minute As Int)
      • SelectedMinuteChanged (Minute As Int)
      • SelectionDone (Hour As Int, Minute As Int)
    • Fields:
      • mBase As B4XView
      • Tag As Object
    • Functions:
      • Class_Globals As String
      • DesignerCreateView (Base As Object, Lbl As Label, Props As Map)
        Base type must be Object
      • getAutoSwitch As Boolean
      • getBackgroundColor As Int
      • getCurrentMode_HourSelection As String
      • getCurrentMode_MinuteSelection As String
      • getMinuteSteps As Int
      • getTextColor As Int
      • getThumbColor As Int
      • getThumbLineColor As Int
      • getTimeFormat As String
      • Initialize (Callback As Object, EventName As String) As String
      • IsInitialized As Boolean
        Tests whether the object has been initialized.
      • Refresh As String
      • setAutoSwitch (Auto As Boolean) As String
      • setBackgroundColor (Color As Int) As String
      • setCurrentMode (Mode As String) As String
      • setMinuteSteps (Steps As Int) As String
      • setTextColor (Color As Int) As String
      • setThumbColor (Color As Int) As String
      • setThumbLineColor (Color As Int) As String
      • setTimeFormat (Format As String) As String
    • Properties:
      • AutoSwitch As Boolean
      • BackgroundColor As Int
      • CurrentMode
      • CurrentMode_HourSelection As String [read only]
      • CurrentMode_MinuteSelection As String [read only]
      • MinuteSteps As Int
      • TextColor As Int
      • ThumbColor As Int
      • ThumbLineColor As Int
      • TimeFormat As String
Changelog
  • 1.00
    • Release
  • 1.01
    • BugFixes
  • 1.02 (read more)
    • BugFixes
    • Add get and set Hours
    • Add get and set Minutes
  • 1.03 (read more)
    • Add SmoothModeChange - Fade in mode change
  • 1.04
    • 12h Format now has a 12 at the top
  • 1.05
    • BugFix
  • 1.06
    • BugFix
  • 1.07
    • Add get CurrentMode
  • 1.08
    • BugFixes
    • Visual Improvements
    • The Thumb is now behind the Text, so you can now use thumb colors with full alpha
    • Add get and set FontSize
      • Default: 15
    • Add get and set SecondRowGap
      • Default: 5dip
  • 1.09
    • BugFix
  • 1.10
    • BugFix in set Hours
  • 1.11
    • B4A BugFix
Have Fun :)
 

Attachments

  • AS TimePicker Example.zip
    10.4 KB · Views: 451
  • AS_TimePicker.b4xlib
    4.2 KB · Views: 107
Last edited:

netsistemas

Active Member
Licensed User
Longtime User
i using you control.
Thanks.
how change from minute to hour panel. (back to previous panel)
 

netsistemas

Active Member
Licensed User
Longtime User
another...
and set hour or minutes?
simil to AS_TimerPicker1.SetMinute and SetHour (and refresh)
 

netsistemas

Active Member
Licensed User
Longtime User
and i view a little bug:
when you select hour: 16, and set to minutes, a retriev to hour, the hour rounded alway are the external, that is 04

16 are internal hour, 04 external our. Set 16, change to minutes - > change to hour. What hour are selected?
 

Alexander Stolte

Expert
Licensed User
Longtime User
Update
  • 1.02
    • BugFixes
    • Add get and set Hours
    • Add get and set Minutes
setMinutes
B4X:
AS_TimerPicker1.Minutes = 30
AS_TimerPicker1.Refresh
setHours
B4X:
AS_TimerPicker1.Hours = 16 '16 o clock
AS_TimerPicker1.Refresh
 

wimpie3

Well-Known Member
Licensed User
Longtime User
Nice work!

I know this is only a MINOR detail, but I think in Android when you've selected the hour, the entire clock fades out and the minutes fade in. Now the switch between them is kind of abrupt.
 

mmieher

Active Member
Licensed User
Longtime User
I cannot figure out why the attached is not setting the indicator to the desired hour or minute position? Trying to set hour to 16 like the example.

And what is up with the log?

B4X:
Waiting for debugger to connect...
Program started.
SelectedHourChanged: 28
SelectedHourChanged: 0
 

Attachments

  • ASDPTest.zip
    2.2 KB · Views: 147

mmieher

Active Member
Licensed User
Longtime User
Update
  • 1.05
    • BugFix
Put a sleep(0) before you set the Hours, is only needed at the start of the form
Thanks. It is better. Selector thing still not moving to 16-o-clock. Why does it change to zero after I set it to 16? That must be the real issue.
B4X:
Waiting for debugger to connect...
Program started.
SelectedHourChanged: 16
SelectedHourChanged: 0
 
Top