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

Status
Not open for further replies.
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:

SS-2016-02-10_17.26.22.png


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:

SS-2016-02-10_17.26.57.png


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
    13.2 KB · Views: 3,538
Last edited:

tdocs2

Well-Known Member
Licensed User
Longtime User
The current implementation of ADP adds a "holder" panel that covers the whole screen with the actual picker at the middle. This makes ADP act as a dialog.

Thank you, Erel.

I realize that ADP is superior, but I was wondering what problems exist with Dialog.Date as I have used it in Android 4.4 and 5.0. I know that it does not handle leap years 1900 and 2100 correctly, but other than that I have not found any problems

Best regards.

Sandy

PS: I did not find this ADP thread until very recently - I have to improve my search skills in the forum.
 

barx

Well-Known Member
Licensed User
Longtime User
As erel states, it is just visualisation issues. On some devices it tries to show the month overview and the picker elements but they don't fit on the screen so it looks bad.
 

seardnA

Member
Licensed User
Longtime User
Please use [ code ] [ /code ] tags (without spaces) when posting code.

Can you upload a small project with only ADP and the problem you encounter?
Rehi !
Can I give it another try with code before I upload a small project?

I read the parameter p.pBirthdate using:
B4X:
Sub BtnBirthDate_LongClick
   DateTime.DateFormat = "MM/dd/yyyy"
   p.pBirthdate= DateTime.Date(ADP.GetDate)
   Log(DateTime.Date(ADP.GetDate))
   Log(P.pBirthdate)
   edtHi.text="Birthdate stored as " & p.pBirthdate
End Sub

with ADP.GetDate as long, DateTime.Date giving back a string to p.pBirthdate which is a string character.

Why do I always get back P.pBirthdate = 0 or

as text "Birthdate stored as 01/01/1970.
 

seardnA

Member
Licensed User
Longtime User
Hi !

p is a class modul
B4X:
Sub Class_Globals
  Public pID As Int
  Public pFirstName, pLastName, pBirthDate, pCountryOfOrigin As String
  Public pLifeExp As Long
End Sub

What I saw when I set a breakpoint at
Sub BtnBirthDate_LongClick
is that the value of selectedDate was always 0
B4X:
Public Sub GetDate As Long
   Return selectedDate
End Sub

The log was always 01/01/1970.
I use DateUtils - Version 1.05; 'AnotherDatePicker - v1.11;B4a 3.2
 
Last edited:

yuval

Member
Licensed User
Longtime User
I moved the code that calls the adp to the activity resume from the activity create, and it solved the problem!!
 

Arf

Well-Known Member
Licensed User
Longtime User
This works great, love it. I am having a small problem though, and thats with the display of the CustomView box in my app - the one if clicked, opens the date picker. I've got some strange border around it I want to get rid of. Pic below, any ideas? I've tried removing borders etc in the designer but no luck.

Screenshot_2015-03-20-19-41-39_zpsa1oymxhl.png
 

Arf

Well-Known Member
Licensed User
Longtime User
Solved, just needed to set the CustomView color to that of my background.
 

B_FISH

Member
Licensed User
Longtime User
Maybe this is already answered.....

But how do you see the designer view for the class itself?

I'm only able to see the designer view for the program that is USING this class. (That is, the DEMO program)

B_FISH
 

B_FISH

Member
Licensed User
Longtime User
Sorry..... I wasn't clear.

When you have more than one module in the IDE, I didn't know how to switch to the Designer (.bal file) for other modules.

It, by default, seems to always shows the main one when first loading the project.

Anyhow I found the way to load the other ones (if any exist) under the Designer menu.

B_FISH
 

padvou

Active Member
Licensed User
Longtime User
Thank you for this Class.
I had to add the following code to see the control:
B4X:
Public Sub Front
    holder.BringToFront
    DrawDays
End Sub
 
Status
Not open for further replies.
Top