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,484 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.
Erel B4X founder Staff member Licensed User Longtime User Dec 15, 2013 #61 DateUtils.TicksToStrings internally calls DateTime.Date(...) & " " & DateTime.Time(...). You should use: Code: Copy Label1.Text = DateTime.Date(Date)
DateUtils.TicksToStrings internally calls DateTime.Date(...) & " " & DateTime.Time(...). You should use: Code: Copy Label1.Text = DateTime.Date(Date)
JTmartins Active Member Licensed User Longtime User Dec 15, 2013 #62 Erel said: DateUtils.TicksToStrings internally calls DateTime.Date(...) & " " & DateTime.Time(...). You should use: Code: Copy Label1.Text = DateTime.Date(Date) Click to expand... Thanks Erel. It does work and problem solved. But I'm so curious of the reason that the initial code gave one result in tablet and a diferent result in the phone, being that the only difference is OS version. All other settings where the same. Living and learning.
Erel said: DateUtils.TicksToStrings internally calls DateTime.Date(...) & " " & DateTime.Time(...). You should use: Code: Copy Label1.Text = DateTime.Date(Date) Click to expand... Thanks Erel. It does work and problem solved. But I'm so curious of the reason that the initial code gave one result in tablet and a diferent result in the phone, being that the only difference is OS version. All other settings where the same. Living and learning.
Erel B4X founder Staff member Licensed User Longtime User Dec 16, 2013 #63 It is not related to the OS. DateUtils.TicksToString always returns both the date and the time components. I can only guess that the time section was not visible on the tablet because it was too long.
It is not related to the OS. DateUtils.TicksToString always returns both the date and the time components. I can only guess that the time section was not visible on the tablet because it was too long.
dibesw Active Member Licensed User Longtime User Dec 19, 2013 #64 HI, I'm trying this DataPicker. When I choose a day, program hide datapicker and write data into label, but there is a possibility that it run event automatically in activity then I can sub any routine? (Excuse my bad english). Thanks!
HI, I'm trying this DataPicker. When I choose a day, program hide datapicker and write data into label, but there is a possibility that it run event automatically in activity then I can sub any routine? (Excuse my bad english). Thanks!
Erel B4X founder Staff member Licensed User Longtime User Dec 19, 2013 #65 You can handle the Closed event: Code: Copy Sub ADP_Closed (Cancelled As Boolean, Date As Long) Log("Cancelled = " & Cancelled & ", Date = " & DateUtils.TicksToString(Date)) End Sub
You can handle the Closed event: Code: Copy Sub ADP_Closed (Cancelled As Boolean, Date As Long) Log("Cancelled = " & Cancelled & ", Date = " & DateUtils.TicksToString(Date)) End Sub
dibesw Active Member Licensed User Longtime User Dec 19, 2013 #66 where should I put this? I put this sub in MAIN... Code: Copy Sub ADP_Closed (Cancelled As Boolean, Date As Long) Msgbox("CLOSED!!!","") Log("Cancelled = " & Cancelled & ", Date = " & DateUtils.TicksToString(Date)) End Sub ...but nothing happens
where should I put this? I put this sub in MAIN... Code: Copy Sub ADP_Closed (Cancelled As Boolean, Date As Long) Msgbox("CLOSED!!!","") Log("Cancelled = " & Cancelled & ", Date = " & DateUtils.TicksToString(Date)) End Sub ...but nothing happens
Erel B4X founder Staff member Licensed User Longtime User Dec 19, 2013 #67 Make sure that you are using the latest version of ADP. See the first post.
Steve Miller Active Member Licensed User Longtime User Feb 23, 2014 #69 Nice control. I came across a problem in displaying the month. It is truncating long month names. February is only showing as "Februa". I tried to adjust the Months spinner to be 160 width, but that makes no difference. What can I do to fix this so it doesn't truncate?
Nice control. I came across a problem in displaying the month. It is truncating long month names. February is only showing as "Februa". I tried to adjust the Months spinner to be 160 width, but that makes no difference. What can I do to fix this so it doesn't truncate?
Erel B4X founder Staff member Licensed User Longtime User Feb 24, 2014 #70 You can either increase the spinner size until it fits or decrease the spinner text size.
Steve Miller Active Member Licensed User Longtime User Feb 25, 2014 #71 I'd prefer to increase the spinner size, but it's not having any effect. I opened the designer and selected datepicker.bal and changed the Months spinner width to 200, and it's not changing the size. I also deleted the datepicker from the page and added it again after increasing the width. Still no luck. Is there more that I need to do, that I'm missing?
I'd prefer to increase the spinner size, but it's not having any effect. I opened the designer and selected datepicker.bal and changed the Months spinner width to 200, and it's not changing the size. I also deleted the datepicker from the page and added it again after increasing the width. Still no luck. Is there more that I need to do, that I'm missing?
Erel B4X founder Staff member Licensed User Longtime User Feb 25, 2014 #72 The spinner width is set in the designer script (it was created before anchors were available).
JohnC Expert Licensed User Longtime User Feb 25, 2014 #73 Erel said: The problem happens because there is a call to AddToActivity in DesignerCreateView that is done with CallSubDelayed. It must use CallSubDelayed because it is not possible to load a layout file while a file is being loaded. The solution is to use CallSubDelayed in your code: Code: Copy Sub Activity_Create(FirstTime As Boolean) Activity.LoadLayout("1") CallSubDelayed(Me, "SetDate") End Sub Sub SetDate ADP.SetDate(DateTime.Now, True) End Sub Click to expand... I am adding the ADP to an activity using the designer, so I am not adding it or initializing it via code. Upon loading of the activity, I want to pre-set the date of the ADP, but when I try to use the ".SetDate" at the end of the Activity_Create sub, it gives a "java.lang.RuntimeException: Object should first be initialized (Label)." error. So, I tried using your CallSubDelayed method above and still I get that error. How can I assign a value to the ADP when the activity is loaded without getting an error because the targetLabel is not initialized yet?
Erel said: The problem happens because there is a call to AddToActivity in DesignerCreateView that is done with CallSubDelayed. It must use CallSubDelayed because it is not possible to load a layout file while a file is being loaded. The solution is to use CallSubDelayed in your code: Code: Copy Sub Activity_Create(FirstTime As Boolean) Activity.LoadLayout("1") CallSubDelayed(Me, "SetDate") End Sub Sub SetDate ADP.SetDate(DateTime.Now, True) End Sub Click to expand... I am adding the ADP to an activity using the designer, so I am not adding it or initializing it via code. Upon loading of the activity, I want to pre-set the date of the ADP, but when I try to use the ".SetDate" at the end of the Activity_Create sub, it gives a "java.lang.RuntimeException: Object should first be initialized (Label)." error. So, I tried using your CallSubDelayed method above and still I get that error. How can I assign a value to the ADP when the activity is loaded without getting an error because the targetLabel is not initialized yet?
Erel B4X founder Staff member Licensed User Longtime User Feb 26, 2014 #74 Can you post the Activity_Create code?
JohnC Expert Licensed User Longtime User Feb 26, 2014 #75 It turned out that I was displaying a msgbox in the activity_create BEFORE I was doing the .setdate function lower in that same sub and for some reason the act of displaying that msgbox caused the targetLabel to not be initialized. When I removed the msgbox statement, the error went away.
It turned out that I was displaying a msgbox in the activity_create BEFORE I was doing the .setdate function lower in that same sub and for some reason the act of displaying that msgbox caused the targetLabel to not be initialized. When I removed the msgbox statement, the error went away.
Xardoz Member Licensed User Longtime User Feb 27, 2014 #76 Sorry for a stupid question.... I am very new to B4A and am trying to use this library in my project. I have referenced DateUtils v1.05 I am running: B4A 3.20 When I enter Dim ADP As in the Globals of the sub pane, I do not get AnotherDatePicker in the intelisense Thank You in Advance ps: The simplest way to add it is with the designer. You should add a CustomView and then set its type. Click to expand... I tried this and AnotherDatePicker does not show up in the designer
Sorry for a stupid question.... I am very new to B4A and am trying to use this library in my project. I have referenced DateUtils v1.05 I am running: B4A 3.20 When I enter Dim ADP As in the Globals of the sub pane, I do not get AnotherDatePicker in the intelisense Thank You in Advance ps: The simplest way to add it is with the designer. You should add a CustomView and then set its type. Click to expand... I tried this and AnotherDatePicker does not show up in the designer
Steve Miller Active Member Licensed User Longtime User Feb 27, 2014 #77 No matter what I do, it will not widen the month. I set the lblSelectedDay to left = 150. I see the label move to the right. But, when I click on the scripts tab, it moves back to center.
No matter what I do, it will not widen the month. I set the lblSelectedDay to left = 150. I see the label move to the right. But, when I click on the scripts tab, it moves back to center.
Erel B4X founder Staff member Licensed User Longtime User Feb 27, 2014 #78 @Xardoz ADP is a class module. You need to add it to your project (Project - Add Existing Module). Steve Miller said: No matter what I do, it will not widen the month. I set the lblSelectedDay to left = 150. I see the label move to the right. But, when I click on the scripts tab, it moves back to center. Click to expand... Go over the script. You will see that the label is layout is set in the script.
@Xardoz ADP is a class module. You need to add it to your project (Project - Add Existing Module). Steve Miller said: No matter what I do, it will not widen the month. I set the lblSelectedDay to left = 150. I see the label move to the right. But, when I click on the scripts tab, it moves back to center. Click to expand... Go over the script. You will see that the label is layout is set in the script.
Xardoz Member Licensed User Longtime User Feb 28, 2014 #79 Erel said: @Xardoz ADP is a class module. You need to add it to your project (Project - Add Existing Module). Go over the script. You will see that the label is layout is set in the script. Click to expand... TY!
Erel said: @Xardoz ADP is a class module. You need to add it to your project (Project - Add Existing Module). Go over the script. You will see that the label is layout is set in the script. Click to expand... TY!
Steve Miller Active Member Licensed User Longtime User Mar 6, 2014 #80 When the datepicker loads, it's blank. If a date is not selected the textbox remains blank, but when executing the GetDate method, it returns today's date. If a date isn't selected, how do I return null? I'm saving the values in a database and if a date is not selected, I need to save a null value, not the current date.
When the datepicker loads, it's blank. If a date is not selected the textbox remains blank, but when executing the GetDate method, it returns today's date. If a date isn't selected, how do I return null? I'm saving the values in a database and if a date is not selected, I need to save a null value, not the current date.