B4A Library [B4X] [XUI] AS DatePickerTimeline

pliroforikos

Active Member
Licensed User
Hello,
Is there any way to allow selection of a small range of days?
For example i need to select days in current year until now and not next days.

Thank you in advance.
 

Alexander Stolte

Expert
Licensed User
Longtime User
Update
  • 1.07
    • Add get and set MaxDate - Will restrict date navigations features of forward, and also cannot swipe the control using touch gesture beyond the max date range
    • Add get and set MinDate - Will restrict date navigations features of backward, and also cannot swipe the control using touch gesture beyond the max date range
    • Add Rebuild - Clears the DatePicker and builds the DatePicker new
Example:
One Week
B4X:
AS_DatePickerTimeline1.MinDate = DateTime.now
AS_DatePickerTimeline1.MaxDate = DateTime.now
AS_DatePickerTimeline1.Rebuild
 

pliroforikos

Active Member
Licensed User
Hello,

I was using

B4X:
    AS_DatePickerTimeline2.Scroll2Date(DateTime.now)
    AS_DatePickerTimeline2_SelectedDateChanged(DateTime.now)

to go and select today.

Using;

B4X:
    AS_DatePickerTimeline2.MinDate = DateUtils.SetDate(DateTime.GetYear(DateTime.now), 1, 1)
    AS_DatePickerTimeline2.MaxDate = DateTime.now
    AS_DatePickerTimeline2.Rebuild

    AS_DatePickerTimeline2.Scroll2Date(DateTime.now)
    AS_DatePickerTimeline2_SelectedDateChanged(DateTime.now)

it stays to December and not scrolling to "DateTime.now"

I tried to scroll it but then it stays to previous week of August.
 

Alexander Stolte

Expert
Licensed User
Longtime User
Update
  • 1.08
    • BugFix
I was using
Now, you just need this:
B4X:
AS_DatePickerTimeline2.MinDate = DateUtils.SetDate(DateTime.GetYear(DateTime.now), 1, 1)
AS_DatePickerTimeline2.MaxDate = DateTime.now
AS_DatePickerTimeline2.Rebuild
AS_DatePickerTimeline2_SelectedDateChanged(DateTime.now)
 

pliroforikos

Active Member
Licensed User
Thank you very much.
It works but the next days of current week are selectable.




i tried

B4X:
Private Sub AS_DatePickerTimeline2_SelectedDateChanged (Date As Long)
    If Date > DateTime.Now Then
        B4XPages.MainPage.eFuncs.toastMsg("Cant select next days", False)
        AS_DatePickerTimeline2_SelectedDateChanged(DateTime.now)
    Else
        selectedDate = $"${DateTime.GetYear(Date)}-${DateTime.GetMonth(Date)}-${DateTime.GetDayOfMonth(Date)} "$
    End If
End Sub

but the selected color remains in next days
 
Last edited:

Alexander Stolte

Expert
Licensed User
Longtime User
Update
  • 1.09
    • BugFixes
The click is now deactivated on dates, thats are lower than the MinDate or higher than the MaxDate.
But you should now use the CustomDrawDate event to show the user, that he can't tap on this dates.
Like:

B4X:
Private Sub AS_DatePickerTimeline2_CustomDrawDay (Date As Long, Views As ASDatePickerTimeline_CustomDrawDay)

    If (AS_DatePickerTimeline2.MaxDate > 0 And DateUtils.SetDate(DateTime.GetYear(Date),DateTime.GetMonth(Date),DateTime.GetDayOfMonth(Date)) > DateUtils.SetDate(DateTime.GetYear(AS_DatePickerTimeline2.MaxDate),DateTime.GetMonth(AS_DatePickerTimeline2.MaxDate),DateTime.GetDayOfMonth(AS_DatePickerTimeline2.MaxDate))) Or (AS_DatePickerTimeline2.MinDate > 0 And DateUtils.SetDate(DateTime.GetYear(Date),DateTime.GetMonth(Date),DateTime.GetDayOfMonth(Date)) < DateUtils.SetDate(DateTime.GetYear(AS_DatePickerTimeline2.MinDate),DateTime.GetMonth(AS_DatePickerTimeline2.MinDate),DateTime.GetDayOfMonth(AS_DatePickerTimeline2.MinDate))) Then
        Views.xlbl_Date.TextColor = xui.Color_ARGB(80,255,255,255)
    End If
    
End Sub
 

asales

Expert
Licensed User
Longtime User
Another great lib. Thanks!

2 questions:
1 - How to start the date in the current day?
I tried with:
AS_DatePickerTimeline2.StartDate = DateTime.Now
but don't works.

2 - I can't scroll the list or page in B4J. In B4A works fine.
I tried putting a button to previous/next week:
AS_DatePickerTimeline2.PreviousWeek
but the calendar stay fixed.

Thanks in advance.
 

Alexander Stolte

Expert
Licensed User
Longtime User
1 - How to start the date in the current day?
is per default on the current day.
If you mean the selected date, then do this:
B4X:
AS_DatePickerTimeline1.SelectedDate = DateTime.Now
2 - I can't scroll the list or page in B4J.
On B4J you need buttons for the navigation.
Be sure the List Mode is on "Paging" in B4J, "List" is not supported.
 

asales

Expert
Licensed User
Longtime User
is per default on the current day.
If you mean the selected date, then do this:
B4X:
AS_DatePickerTimeline1.SelectedDate = DateTime.Now
I tried this code, but the calendar (when open the app) still show 1 Jan and not 17 Aug.
I want to start the calendar in the actual day (17 Aug).


What am I doing wrong?
 

asales

Expert
Licensed User
Longtime User
ASViewPager = 1.34

I think the problem is with the devices.

I tested in a Redmi 9A and in a Samsung A71, and the calendar don't change (still 1 Jan).

I tested in a Moto G7 and it shows the current day

All dates in devices is correct.
Strange behavior.
 

asales

Expert
Licensed User
Longtime User
Test it in Release mode.
Yes, I use the release mode.
Nothing change with the new version, but I see another behaviour:
- If I compile using Release (or Release Obfuscated) mode, it don't show the current day in Redmi 9A and A71.
- If I compile using the Debug mode, it shows correctly !!!
 

asales

Expert
Licensed User
Longtime User
Can you please download it again?
I'm using now a Do While loop and it seems working
Download again then lib and the example.

- Release and Release (Obfuscated) modes. Don't see the List and don't show the actual day in Paging:


- Debug mode - works fine:


 

pliroforikos

Active Member
Licensed User
Same issue.
- Moto G4 (Android 7) - Release and Debug - OK
- A71 (Android 12), Redmi 9A (Android 10) - Debug OK - Release: don't show list and don't change the date.
Thanks for your support.
I don't know if it helps but lib works fine in Xiaomi 8T and Xiaomi 7A. Tomorrow i'll try to install in XIaomi 9A if my daughter give it to me
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…