Share My Creation A Windows like DatePicker (DateDialog)

In stead of the usual DateDialog I was in need of a DateDialog like the Windows DatePicker, and programmed this DatePicker activity module. I think it gives the user at better overview of the days of the month to select from.

The DatPicker should be added as a new Activity module and called with StartActivity.
When the user selects a day, it can be read from the calling Activity. (Under Activity.Resume).

Please see corwin42's code below. He has made some great improvements to the module.

/Erik Bertelsen
 

Attachments

  • DatePicker.zip
    342.8 KB · Views: 4,931
Last edited:

Merlot2309

Active Member
Licensed User
Longtime User
Hello Erik and very welcome to the forum.

This does look great to me :icon_clap:
Will be a nice puzzle (for me) if I can implement dates from a database.

Thank you.

Helen.
 

alfcen

Well-Known Member
Licensed User
Longtime User
Hi Erik,

Congratulations on a fine solution. This is a lovely alternative. :sign0060:

A hint if I may, instead of lv.Scale, you can use the unit "dip" for scaling. This will save you several multiplications and contribute to shorter (and slightly faster) code.

I am planning to create a moon phase calendar based on your work. Initially, I thought of a graphical solution using a Canvas, however, your approach is superior because moon data for every day can be popped up upon a tap on each day button.

No apologies for your English, please, most forum members are non-native English speakers while the native English speakers appreciate our effort.

Cheers
Robert
 

bazp

Member
Licensed User
Longtime User
I used the date picker for my book buddy app. ( I gave you credit) It was very easy to use.

I changed it so that when you picked a date that already existed it would display the month/year and highlight the day in blue.

I also added (Via MERLOT2309) a long click that moved it back and forth 1 year.

You did great work. I will use the date picker from now on in my projects.
 

corwin42

Expert
Licensed User
Longtime User
Nice piece of work.

I have changed it slightly:

- Use AHLocale library for day and month names so it will work in any language
- Use AHLocale library for first day of week so it will use the setting of the device locale.
- Changed lv.Scale multiplier to "dip" values
- Button texts can be set externally so you can make translations to them (see example)
- some minor changes to layout so it will better fit on 320x240 devices.
- Removed DoEvents in Activity_Create. It's not needed and makes a strange jump when opening the dialog.
- added german translation to the example project

Your module is a great example to show what can be done with AHLocale library.
 

Attachments

  • DatePicker.zip
    9.2 KB · Views: 1,587

Merlot2309

Active Member
Licensed User
Longtime User
Hello Markus,

Could it be that the AHL lib isn't included?

Greets,
Helen

Oeps. First posted and then thought I should have a look at the libs ..................
Sorry!
 
Last edited:

Cableguy

Expert
Licensed User
Longtime User
It should NOT be, as any other Lib, it suld be made available only to registered users in the Libraries sub-forum...This is a "Good Practice" way of doing things, and assuring that un-registered user do not get for free what took us some effort in creating...
The Date picker it-self, is a code Module, ans therefore does not follow these rules
 

aad250

New Member
Licensed User
Longtime User
Thanks

Hello all,

Thanks for all the positive feedback and hints. Thanks Markus for the AHLocale hint and improvements. I am on vacation and have only limited access to internet. I will be back nextweek and look at the code.

Erik
 

aad250

New Member
Licensed User
Longtime User
Nice piece of work.

I have changed it slightly:

- Use AHLocale library for day and month names so it will work in any language
- Use AHLocale library for first day of week so it will use the setting of the device locale.
- Changed lv.Scale multiplier to "dip" values
- Button texts can be set externally so you can make translations to them (see example)
- some minor changes to layout so it will better fit on 320x240 devices.
- Removed DoEvents in Activity_Create. It's not needed and makes a strange jump when opening the dialog.
- added german translation to the example project

Your module is a great example to show what can be done with AHLocale library.

Thanks Markus for the improvements. The use of AHLocale is much more elegant.

The DoEvents was because I had an idea of centering the day names over the corresponding columns, so I needed to retrieve the width of the day labels after setting the text into them. And so you must do a DoEvents in order to let the labels resize. But I never coded that part, so the DoEvents is not needed. Does anyone know of a way to determine the with of a text?

Erik
 

gawie007

Member
Licensed User
Longtime User
Modification for Tablet or anything else

Firstly: Thanks Erik & Markus - excellent work!

I needed a Calendar for my Tablet.
I have modified the code so that it can easily be scaled. Change this in the first few lines of the "Kalendar" activity.
It has been a while since I have programmed so please excuse my not-so-eloquent coding.

I did see that it could only be used in portrait. I have changed this to rotate and seems to work fine.

Kind regards

Gavin
 
Last edited:

gawie007

Member
Licensed User
Longtime User
DatePicker

Found a problem with with my code for smaller screens and made all text sizes scaleable from a constant variable.
 

Attachments

  • DatePicker.zip
    336.5 KB · Views: 1,186

aad250

New Member
Licensed User
Longtime User
Hi Gavin,

Thanks for your modifications.

I like your text scaling and your modification that the day text is now centered above the buttons. Looks much better now - Nice piece of work ;)

I cannot use a scale factor greater than 1.0 on my Sony Eriksson Xperia Arc, and when rotating to landscape mode I cannot see the whole calendar. It is not possible to scrool the view. Maybe someone could program that :D

Erik
 

henry1311

Member
Licensed User
Longtime User
By the excellent work done by aad250, corwin42 gawie007 and I was inspired to add something to the very useful tools 'datepicker'.
I added, as well as some graphics (for those who like it!) Can also position themselves in a default date, highlighted in blue to distinguish it from the red 'today', thus I added the button 'default' to move on that date from within the same activity.
I also added the ability to move from year to year and with special buttons 'previous' and 'next' either directly by typing the year.
Greetings all
Enrico

PS: This text was translated with google translate.


-------------------
Italiano :
Dall'ottimo lavoro fatto da aad250, corwin42 e gawie007 ho preso spunto per aggiungere qualcosa all'utilissimo tools datepicker.
Ho aggiunto, oltre ad un pò di grafica (a chi piacerà!) anche la possibilità di posizionarsi in una data di default, evidenziata in blue per distinguerla da quella rossa 'today', conseguentemente ho aggiunto anche il bottone 'default' per posizionarsi su tale data anche dall'interno della stessa activity.
Ho inoltre aggiunto la possibilità di spostarsi di anno in anno sia con appositi bottoni 'precedente' e 'successivo' sia direttamente digitando l'anno.
Ciao
Enrico
-------------------
 

Attachments

  • datepicker3.zip
    10.8 KB · Views: 1,397

b2mvga

Member
Licensed User
Longtime User
Excelent!!

Excelent work!!

I am from Brazil and use this calender on my project!

Great!
 

anil

New Member
Licensed User
Longtime User
How to add two datepickers in single layout file

Dear Fellow,

I just bought recently this app, its nice and started to learning.

I was trying to implement two date pickers in single layout file , can someone share piece code which will be helpful.

Thanks for your time , thanks for sharing this library. You guys rock:sign0098:
 

TyneBridges

Member
Licensed User
Longtime User
Sorry, I'm probably being dim again as no-one here has reported any problems. I have put Corwin42's library into my project. All the files are in my Libraries folder, in a subfolder called "DatePicker". Within that I have DatePicker.b4a, KalenderActivity.bas and Objects and Files folders. The Files folder contains kalender.bal, AHLocale (version 1.12) is listed in my referenced libraries and KalenderActivity is in the top right panel of the Modules tab in my main window.

My app compiles and starts to run. However, at the point when the date picker should be invoked, the app stops with the runtime error "java.io.FileNotFoundException: kalender.bal". I've checked the spelling and a file of that name is there, in the same place in the file structure as in the zip file. Can anyone tell me why it isn't being found?
 
Top