B4A Library [B4X] AS WheelDateTimePicker - based on ASWheelPicker

This is a date and time picker in IOS picker design.

This library is based on the ASWheelPicker, without it the library will not work.

EQ5gfV8j4u2d3PaEtXi6p57dQCY9h7883CRjIizpVHqLx7YXhY.jpeg

ASWheelDateTimePicker
Author: Alexander Stolte
Version: 1.00

  • ASWheelDateTimePicker_MonthName
    • Fields:
      • April As String
      • August As String
      • December As String
      • February As String
      • IsInitialized As Boolean
        Tests whether the object has been initialized.
      • January As String
      • July As String
      • June As String
      • March As String
      • May As String
      • November As String
      • October As String
      • September As String
    • Functions:
      • Initialize
        Initializes the fields to their default value.
  • ASWheelDateTimePicker_MonthNameShort
    • Fields:
      • April As String
      • August As String
      • December As String
      • February As String
      • IsInitialized As Boolean
        Tests whether the object has been initialized.
      • January As String
      • July As String
      • June As String
      • March As String
      • May As String
      • November As String
      • October As String
      • September As String
    • Functions:
      • Initialize
        Initializes the fields to their default value.
  • ASWheelDateTimePicker_WeekNameShort
    • Fields:
      • Friday As String
      • IsInitialized As Boolean
        Tests whether the object has been initialized.
      • Monday As String
      • Saturday As String
      • Sunday As String
      • Thursday As String
      • Tuesday As String
      • Wednesday As String
    • Functions:
      • Initialize
        Initializes the fields to their default value.
  • AS_WheelDateTimePicker
    • Events:
      • SelectedDateChanged (Date As Long)
      • SelectedTimeChanged (Hour As Int, Minute As Int)
    • Fields:
      • mBase As B4XView
      • Tag As Object
    • Functions:
      • Class_Globals As String
      • CreateASWheelDateTimePicker_MonthName (January As String, February As String, March As String, April As String, May As String, June As String, July As String, August As String, September As String, October As String, November As String, December As String) As ASWheelDateTimePicker_MonthName
      • CreateASWheelDateTimePicker_MonthNameShort (January As String, February As String, March As String, April As String, May As String, June As String, July As String, August As String, September As String, October As String, November As String, December As String) As ASWheelDateTimePicker_MonthNameShort
      • CreateASWheelDateTimePicker_WeekNameShort (Monday As String, Tuesday As String, Wednesday As String, Thursday As String, Friday As String, Saturday As String, Sunday As String) As ASWheelDateTimePicker_WeekNameShort
      • DesignerCreateView (Base As Object, Lbl As Label, Props As Map) As String
        Base type must be Object
      • getHour As Int
      • getMinute As Int
      • Initialize (Callback As Object, EventName As String) As String
      • IsInitialized As Boolean
        Tests whether the object has been initialized.
    • Properties:
      • Hour As Int [read only]
      • Minute As Int [read only]
Changelog
  • 1.00
    • Release
  • 1.01
    • BugFixes
  • 1.02
    • Add set Hour
    • Add set Minute
    • Add set Date
  • 1.03
    • Add Refresh
  • 1.04
    • BugFixes
    • PickerType = DatePicker - The days in the month now adjust automatically
    • Add Designer Property TextColor
    • Add Designer Property FadeColor
    • Add Designer Property HapticFeedback
  • 1.05
    • Add Designer Property TodayText
      • Default: Today
    • Add get and set TodayText - Call Refresh if you change something
  • 1.06
    • BugFixes
  • 1.07
    • BugFixes - AM and PM mode works now as expected
    • BugFixes - setDate Number of days is now adjusted
Have Fun :)
 

Attachments

  • AS WheelDateTimePicker Example.zip
    178.4 KB · Views: 147
  • AS_WheelDateTimePicker.b4xlib
    5 KB · Views: 9
Last edited:

MarcoRome

Expert
Licensed User
Longtime User
Hi dear.

IMG-20220921-WA0000.jpg


A few questions:
1. How can I set the background color. In this case I have entered the same color as the Panel but it is always black. For example i set the same color as the panel in the designer but as you can see from the image the object remains black
2. How can i set the time to automatically exit the current time, for the moment always hour: 00 minute: 00. As you can see from the image it starts with today but the time is always set to zero Even if i use
B4X:
AS_WheelDateTimePicker1.Hour = 10
dont changes
3. I noticed that if the panel starts in invisible mode, when it comes back visible and you try to change date or time with object AS_WheelDateTimePicker it crashes.

Attached example

I think it is the best datetimepicker available for ios and droid

Thank you @Alexander Stolte
 

Attachments

  • Example.zip
    9.7 KB · Views: 12

Alexander Stolte

Expert
Licensed User
1. How can I set the background color. In this case I have entered the same color as the Panel but it is always black. For example i set the same color as the panel in the designer but as you can see from the image the object remains black
Don't use colors with a alpha, lower than 255.
2. How can i set the time to automatically exit the current time, for the moment always hour: 00 minute: 00. As you can see from the image it starts with today but the time is always set to zero Even if i use
B4X:
AS_WheelDateTimePicker1.Hour = 10
dont changes
Fixed in the next update of the 2 libs.
3. I noticed that if the panel starts in invisible mode, when it comes back visible and you try to change date or time with object AS_WheelDateTimePicker it crashes.
This is the native behavior of android scrolllist. I added a xCustomListView to the panel and scrolled to the last item while the panel was still invisible. The result, the list did not scroll when the list was invisible.
So unfortunately there is nothing I can do. The WheelPicker must be visible when building. You can also load the DatePicker only when you need it, in release mode this is fast, I also do this in combination with the FloatingPanel.
 

astronald

Member
Licensed User
Longtime User
Hi Alexander, have nice programming day
set hour and minute how works?

Set Hour and minute:
wp.Hour = DateTime.GetHour(Inicio)
wp.Minute = DateTime.GetMinute(Inicio)
Log(DateTime.GetHour(Inicio) & "," & wp.Hour)
Log(DateTime.GetMinute(Inicio) & "," & wp.Minute)

log:
Inicio= 14:03
14,11
3,3

at the phone
hora.png



What is worng?
Thanks for your help.
 

MarcoRome

Expert
Licensed User
Longtime User
Hi dear
if i have this code
B4X:
DateTime.DateFormat = "MM/dd/yyyy"
AS_WheelDateTimePicker1_dalla_data.Date = DateTime.DateParse($"01/01/${DateTime.GetYear(DateTime.Now)}"$)
AS_WheelDateTimePicker1_dalla_data.Refresh

The date doesn't change, it is always today's date.
Any solution ?
Thank you
 

MarcoRome

Expert
Licensed User
Longtime User
Another thing.
if you enter Picker Type: DatePicker
select today's date 30/09/2022 by default, but unfortunately it also goes to 31/09 (which does not exist) causing the following crash

Error: Invalid value: d.C.20220931 000000
Error occurred on line: 878 (ASWheelPicker)
java.lang.NumberFormatException: For input string: "invalid date"
at jdk.internal.math.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:2054)
 

MarcoRome

Expert
Licensed User
Longtime User
Hi dear
if i have this code
B4X:
DateTime.DateFormat = "MM/dd/yyyy"
AS_WheelDateTimePicker1_dalla_data.Date = DateTime.DateParse($"01/01/${DateTime.GetYear(DateTime.Now)}"$)
AS_WheelDateTimePicker1_dalla_data.Refresh

The date doesn't change, it is always today's date.
Any solution ?
Thank you
if you compile it works (does not show the 31st for September) maybe it's just a problem in debug (takes some time to load the object? ). In any case, there are no problems in compiling
 

MarcoRome

Expert
Licensed User
Longtime User
Hi dear
if i have this code
B4X:
DateTime.DateFormat = "MM/dd/yyyy"
AS_WheelDateTimePicker1_dalla_data.Date = DateTime.DateParse($"01/01/${DateTime.GetYear(DateTime.Now)}"$)
AS_WheelDateTimePicker1_dalla_data.Refresh

The date doesn't change, it is always today's date.
Any solution ?
Thank you
if you change the date later, for example when you view the panel where the object is inserted. Work, change the date 👍
 

Alexander Stolte

Expert
Licensed User
Update
  • 1.07
    • BugFixes - AM and PM mode works now as expected
    • BugFixes - setDate Number of days is now adjusted
set hour and minute how works?
AM and PM mode works now as expected.
The date doesn't change, it is always today's date.
Any solution ?
Put a Sleep(0) before you change the date.
if you enter Picker Type: DatePicker
select today's date 30/09/2022 by default, but unfortunately it also goes to 31/09 (which does not exist) causing the following crash
setDate Number of days is now adjusted
 

MarcoRome

Expert
Licensed User
Longtime User
Update
  • 1.07
    • BugFixes - AM and PM mode works now as expected
    • BugFixes - setDate Number of days is now adjusted

AM and PM mode works now as expected.

Put a Sleep(0) before you change the date.

setDate Number of days is now adjusted

with new Rel. i have this error:

Error occurred on line: 0 (ASWheelPicker)
java.lang.Exception: Sub xwp_wheel_itemchange signature does not match expected signature.
public static anywheresoftware.b4a.pc.RemoteObject net.taxitaormina.app.as_wheeldatetimepicker_subs_0._xwp_wheel_itemchange(anywheresoftware.b4a.pc.RemoteObject,anywheresoftware.b4a.pc.RemoteObject,anywheresoftware.b4a.pc.RemoteObject,anywheresoftware.b4a.pc.RemoteObject) throws java.lang.Exception
class anywheresoftware.b4a.pc.RemoteObject, class anywheresoftware.b4a.pc.RemoteObject, class anywheresoftware.b4a.pc.RemoteObject,
 
Top