Mar 21, 2013 Replies: 244 This is an old version. Latest version is included in XUI Views: https://www.b4x.com/android/forum/threads/100836/#content AnotherDatePicker is an inline date picker: The advantage of this class over the built-in dialog (DateDialog from the Dialogs library) is that you can easily customize it as needed. Most of the layout is created with the visual designer and designer script. ADP.GetDate returns the selected date. The months names and days names are based on the device locale. In order to use this class in your code you should add AnotherDatePicker class, reference DateUtils library and add DatePicker layout file to the Files tab. Starting from v2.0, ADP should be added as a custom view from the designer: v2.0 - Better support for visual designer and more configurable options (including first day of week). v1.11 - Fixes an issue with SetDate that is called before the view is ready. v1.10 - Adds a Closed event. See the attached example. Attachments AnotherDatePicker.zip AnotherDatePicker.zip 13.2 KB · Views: 4,463 Last edited: Feb 18, 2019 Click to expand...
This is an old version. Latest version is included in XUI Views: https://www.b4x.com/android/forum/threads/100836/#content AnotherDatePicker is an inline date picker: The advantage of this class over the built-in dialog (DateDialog from the Dialogs library) is that you can easily customize it as needed. Most of the layout is created with the visual designer and designer script. ADP.GetDate returns the selected date. The months names and days names are based on the device locale. In order to use this class in your code you should add AnotherDatePicker class, reference DateUtils library and add DatePicker layout file to the Files tab. Starting from v2.0, ADP should be added as a custom view from the designer: v2.0 - Better support for visual designer and more configurable options (including first day of week). v1.11 - Fixes an issue with SetDate that is called before the view is ready. v1.10 - Adds a Closed event. See the attached example.
barx Well-Known Member Licensed User Longtime User Mar 21, 2013 #2 Been looking for a good alternative to the date dialog as that seems to go all wrong looking when target sdk is high e.g. 17
Been looking for a good alternative to the date dialog as that seems to go all wrong looking when target sdk is high e.g. 17
AscySoft Active Member Licensed User Longtime User Mar 21, 2013 #3 This is a nice class. Keep them coming! Thanks
barx Well-Known Member Licensed User Longtime User Mar 29, 2013 #4 I would just like to post an 'in use' pic of this date picker in action. I like this class and it has helped solve my issue with the date dialog available in the dialogs library. I have made s few UI tweak (but that is the joy of classes, right?) Thanks Erel
I would just like to post an 'in use' pic of this date picker in action. I like this class and it has helped solve my issue with the date dialog available in the dialogs library. I have made s few UI tweak (but that is the joy of classes, right?) Thanks Erel
Erel B4X founder Staff member Licensed User Longtime User Mar 29, 2013 #5 Looks great! Can you upload your class (its looks better than the original...)?
barx Well-Known Member Licensed User Longtime User Mar 29, 2013 #6 I just want to check that it works good in a couple more devices then yes, of course I will upload it. I didn't change alot to be honest. Just a couple of tweaks.
I just want to check that it works good in a couple more devices then yes, of course I will upload it. I didn't change alot to be honest. Just a couple of tweaks.
barx Well-Known Member Licensed User Longtime User Mar 29, 2013 #7 As promised here is my edit (See attached below). Please note that I only edited a few minor UI things, nothing special or functional. A few of the colors are slightly different to my screenshot, mainly due to, the app I posted screenshot from uses a Custom Light theme, so default texts are dark. Applying that to the sample would just complicate matters. Anybody that uses Erel original class files, one thing I would add to the DatePicker designer layout script is: Add Code: Base.Height = Min(300dip, 100%y) Just after Code: AutoScaleAll If Erel agrees with this, maybe he will update the original for those that don't read past post #1 On my phone 480x800 I found that the bottom of the date picker would be cropped slightly in landscape mode. Adding the above line solves that issue. Updated to reflect Erels update to DateUtils (now v1.03) Thanks again Erel, great class. Attachments AnotherDatePicker_BarxEdit.zip AnotherDatePicker_BarxEdit.zip 13.9 KB · Views: 2,200 Last edited: Mar 29, 2013
As promised here is my edit (See attached below). Please note that I only edited a few minor UI things, nothing special or functional. A few of the colors are slightly different to my screenshot, mainly due to, the app I posted screenshot from uses a Custom Light theme, so default texts are dark. Applying that to the sample would just complicate matters. Anybody that uses Erel original class files, one thing I would add to the DatePicker designer layout script is: Add Code: Base.Height = Min(300dip, 100%y) Just after Code: AutoScaleAll If Erel agrees with this, maybe he will update the original for those that don't read past post #1 On my phone 480x800 I found that the bottom of the date picker would be cropped slightly in landscape mode. Adding the above line solves that issue. Updated to reflect Erels update to DateUtils (now v1.03) Thanks again Erel, great class.
NJDude Expert Licensed User Longtime User Mar 29, 2013 #8 NICE!! However, there are some issues: 1- Today is March 29th, and I don't see that date HERE (March has 31 days) 2- Tapping on the TODAY button at the button, brings the right date to the label, however the "blank square" still remains. 3- If you tap on March 28, the "blank square" goes away, but, tapping on the TODAY button brings it back. 4- There are other months containing the wrong number of days, check December 2013 for example. I've tried that on 4 different devices, same deal. Last edited: Mar 29, 2013
NICE!! However, there are some issues: 1- Today is March 29th, and I don't see that date HERE (March has 31 days) 2- Tapping on the TODAY button at the button, brings the right date to the label, however the "blank square" still remains. 3- If you tap on March 28, the "blank square" goes away, but, tapping on the TODAY button brings it back. 4- There are other months containing the wrong number of days, check December 2013 for example. I've tried that on 4 different devices, same deal.
Erel B4X founder Staff member Licensed User Longtime User Mar 29, 2013 #9 Do you get these errors with the original class as well? Works fine here.
NJDude Expert Licensed User Longtime User Mar 29, 2013 #10 Same thing on both, the original and the modified. These are the results (2013): Jan: OK Feb: OK Mar: WRONG Apr: OK May: WRONG Jun: OK Jul: WRONG Aug: OK Sep: OK Oct: WRONG Nov: OK Dec: WRONG Last edited: Mar 29, 2013
Same thing on both, the original and the modified. These are the results (2013): Jan: OK Feb: OK Mar: WRONG Apr: OK May: WRONG Jun: OK Jul: WRONG Aug: OK Sep: OK Oct: WRONG Nov: OK Dec: WRONG
Erel B4X founder Staff member Licensed User Longtime User Mar 29, 2013 #11 Which locale is set on your device? What is the value of: Code: Log(DateUtils.NumberOfDaysInMonth(3, 2013))
Which locale is set on your device? What is the value of: Code: Log(DateUtils.NumberOfDaysInMonth(3, 2013))
NJDude Expert Licensed User Longtime User Mar 29, 2013 #12 Erel said: Which locale is set on your device? What is the value of: Code: Log(DateUtils.NumberOfDaysInMonth(3, 2013)) Click to expand... It returns 28
Erel said: Which locale is set on your device? What is the value of: Code: Log(DateUtils.NumberOfDaysInMonth(3, 2013)) Click to expand... It returns 28
Erel B4X founder Staff member Licensed User Longtime User Mar 29, 2013 #13 Which locale is selected in your device? You can see it under Settings - Language and Input (or Locale and text).
Which locale is selected in your device? You can see it under Settings - Language and Input (or Locale and text).
NJDude Expert Licensed User Longtime User Mar 29, 2013 #14 Erel said: Which locale is selected in your device? You can see it under Settings - Language and Input (or Locale and text). Click to expand... Oops, forgot to answer that: us_EN
Erel said: Which locale is selected in your device? You can see it under Settings - Language and Input (or Locale and text). Click to expand... Oops, forgot to answer that: us_EN
Erel B4X founder Staff member Licensed User Longtime User Mar 29, 2013 #15 I forgot to ask, which time zone is selected?
Erel B4X founder Staff member Licensed User Longtime User Mar 29, 2013 #17 Good. I believe that I found the problem. Please update DateUtils.NumberOfDaysInMonth with this code and test it again: Code: Public Sub NumberOfDaysInMonth(Month As Int, Year As Int) As Int Dim Ticks As Long = SetDate(Year, Month, 1) Dim nextMonth As Long = DateTime.Add(Ticks, 0, 1, 0) Dim res As Int = Round((nextMonth - Ticks) / DateTime.TicksPerDay) Return res End Sub
Good. I believe that I found the problem. Please update DateUtils.NumberOfDaysInMonth with this code and test it again: Code: Public Sub NumberOfDaysInMonth(Month As Int, Year As Int) As Int Dim Ticks As Long = SetDate(Year, Month, 1) Dim nextMonth As Long = DateTime.Add(Ticks, 0, 1, 0) Dim res As Int = Round((nextMonth - Ticks) / DateTime.TicksPerDay) Return res End Sub
Erel B4X founder Staff member Licensed User Longtime User Mar 29, 2013 #19 Great. Thank you for your help. I will update the relevant files.
Erel B4X founder Staff member Licensed User Longtime User Mar 29, 2013 #20 The project in the first post was updated with DateUtils v1.03. This is an important update. The following line was added to the designer script: Code: Base.Height = Min(100%y, Base.Height) This is relevant for phones in landscape orientation.
The project in the first post was updated with DateUtils v1.03. This is an important update. The following line was added to the designer script: Code: Base.Height = Min(100%y, Base.Height) This is relevant for phones in landscape orientation.