B4A Library [Class] AnotherDatePicker - A simple "web style" date picker

Status
Not open for further replies.

JTmartins

Active Member
Licensed User
Longtime User
DateUtils.TicksToStrings internally calls DateTime.Date(...) & " " & DateTime.Time(...).

You should use:
B4X:
Label1.Text = DateTime.Date(Date)

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.
 

dibesw

Active Member
Licensed User
Longtime User
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!
 

dibesw

Active Member
Licensed User
Longtime User
where should I put this?
I put this sub in MAIN...
B4X:
Sub ADP_Closed (Cancelled As Boolean, Date As Long)
  Msgbox("CLOSED!!!","")
  Log("Cancelled = " & Cancelled & ", Date = " & DateUtils.TicksToString(Date))
End Sub
...but nothing happens
 

Steve Miller

Active Member
Licensed User
Longtime User
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?
 

Steve Miller

Active Member
Licensed User
Longtime User
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?
 

JohnC

Expert
Licensed User
Longtime User

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?
 

JohnC

Expert
Licensed User
Longtime User

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
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.
I tried this and AnotherDatePicker does not show up in the designer
 

Steve Miller

Active Member
Licensed User
Longtime User
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
@Xardoz ADP is a class module. You need to add it to your project (Project - Add Existing Module).

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.
Go over the script. You will see that the label is layout is set in the script.
 

Steve Miller

Active Member
Licensed User
Longtime User
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.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…