B4A Library [B4X] AS WheelDateTimePicker - based on ASWheelPicker

MarcoRome

Expert
Licensed User
Longtime User
Hi dear.



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: 253

Alexander Stolte

Expert
Licensed User
Longtime 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.
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

Active 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



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
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
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
Longtime 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:

 

astronald

Active Member
Licensed User
Longtime User
Hi Alexander
i modified this, please correct me if this is wrong
Gert Hour:
Public Sub getHour As Int
    Dim hora As Int = xwp_Wheel.GetSelectedItem(IIf(m_Date,1,0)).Value
    If xwp_Wheel.GetSelectedItem(IIf(m_Date,3,2)).Text.EqualsIgnoreCase("PM") And xwp_Wheel.GetIndex(IIf(m_Date,1,0)) > 0 Then
        hora = hora +12
    End If
    Return hora
End Sub

and this another suggestion, taking advantage of that DateUtils Locale MonthNames from device

Get Month Names:
Public Sub 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
    Dim t1 As ASWheelDateTimePicker_MonthName
    t1.Initialize
    t1.January = DateUtils.GetMonthsNames.Get(0)
    t1.February = DateUtils.GetMonthsNames.Get(1)
    t1.March = DateUtils.GetMonthsNames.Get(2)
    t1.April = DateUtils.GetMonthsNames.Get(3)
    t1.May = DateUtils.GetMonthsNames.Get(4)
    t1.June = DateUtils.GetMonthsNames.Get(5)
    t1.July = DateUtils.GetMonthsNames.Get(6)
    t1.August = DateUtils.GetMonthsNames.Get(7)
    t1.September = DateUtils.GetMonthsNames.Get(8)
    t1.October = DateUtils.GetMonthsNames.Get(9)
    t1.November = DateUtils.GetMonthsNames.Get(10)
    t1.December = DateUtils.GetMonthsNames.Get(11)
    Return t1
    
End Sub
 

Alexander Stolte

Expert
Licensed User
Longtime User
i modified this, please correct me if this is wrong
The question is, why?
Either you have the wheelPicker in 24 hour format, then you select 0-23, or you have AM/PM, then you can only select 0-11, so you don't have to convert it?
 

astronald

Active Member
Licensed User
Longtime User
A question How i change FadeColor And TextColor Programatically,
I try with this but not succes!
Color:
    xwp_Wheel.FadeColor = m_FadeColor
    xwp_Wheel.ItemTextProperties.TextColor = m_TextColor
    xwp_Wheel.Refresh

 

Alexander Stolte

Expert
Licensed User
Longtime User
Update
  • 1.08
    • Add get and set FadeColor
    • Add get and set TextColor
    • Add get and set SelectorColor
    • Add get and set BackgroundColor
    • MonthName now comes from the DateUtils

When I change PM And get Hour This is 12 + Selected item
True, but then you should convert that outside the library, I don't know the 12 hour format well as I live in 24 format.

A question How i change FadeColor And TextColor Programatically,
don't do it in the .bas file and tell me that the properties are missing, so i can make an update
 

astronald

Active Member
Licensed User
Longtime User
Thanks very Much, but set textColor only afect new items as 31, i think is necesary Colored all items
 
Last edited:
Cookies are required to use this site. You must accept them to continue using the site. Learn more…