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,740
Last edited:

daveinhull

Active Member
Licensed User
Longtime User
Hi Erel,

Many thanks, but my mistake (late night syndrome), sorry how do I know when it gets focus. I have a simple form with an editbox and the anotherdatepicker on it. When I click the anotherdatepicker the date selector pops up, but the curse is left in the editbox and therefore I can't close the softkeyboard, or am I missing something?

Thanks in advance
Dave
 

daveinhull

Active Member
Licensed User
Longtime User
Hi Erel,

Yes although I've just got to catch a train, so will shortly.

Many thanks for your help.

Dave
 

daveinhull

Active Member
Licensed User
Longtime User
Hi Erel,

I've uploaded the test file.

On my system the Edit Box (mainPlace) FocusChanged doesn't fire ......

Dave
 

Attachments

  • UploadZip.zip
    13.7 KB · Views: 288

daveinhull

Active Member
Licensed User
Longtime User
Hi Erel

That is what I was doing. The AnotherDateTime and the EditBox were on a panel. When I wanted them, I made the panel visible and did a AnotherDatePicker.Show so that it appeared first thing. So I select the date and it loads it into the field (fine) and then go to the EditBox and the soft keyboard pops up (fine). However, if I then click on the AnotherDatePicker the date selector pops up, but the cursor is left on the EditBox and the soft keyboard is still visible. I.e. I haven't used .Show again, just moved focus.

Thoughts?
Dave
 

daveinhull

Active Member
Licensed User
Longtime User
Hi Erel,

I can't call ime.HideKeyboard because I don't receive an event saying that the EditBox has lost focus (because if you look) it doesn't actually loose focus when I select the AnotherDatePicker control.

Did you see the uploaded test file? In it the EditBox focus change event doesn't get fired.....

Dave
 

daveinhull

Active Member
Licensed User
Longtime User
Hi Erel,

Because I only use .Show once when the panel becomes visible. While the data entry panel is visible (i.e. collecting either the date-AnotherDatePicker or the place-EditBox) I want to be able to allow the user to click in the EditBox or the AnotherDatePicker to enter the data and then press return to go back to the main program.

While this is happening I don't use .Show for the ANotherDatePicker. If I select the EditBox the AnotherDatePicker window hides and if I click on the AnotherDatePicker date field, it comes back again, but the cursor doesn't leave the EditBox. Surely if I select the AnotherDatePicker (as a different control) then EditBox should lose focus? The ofcus is clearly not with the EditBox anymore if the user is selecting a date?

Thanks
Dave
 

daveinhull

Active Member
Licensed User
Longtime User
Hi Erel,

Anyway thanks for trying to help.

I really dont understand what you mean by "that is not how Android works". If I have two EditBoxes and I switch between then the focus changes and I get events.

Anyway I don't want to waste your time, but I'll have to do something else because your solution does not work in my use case. It's not semantically correct even if it is syntactically correct.

Thanks again for your patience.
 

daveinhull

Active Member
Licensed User
Longtime User
Hi Erel,

Yes, but isn't the AnotherDatePicker using edit fields at all? or do you only get a change of focus event with EditBoxes? This is where my misunderstanding must be.

Anyway, thanks again and I'll work another solution.

Dave
 

daveinhull

Active Member
Licensed User
Longtime User
Hi Erel,

Ok, so I've sorted it. I've created a second EditText on the panel and hidden the AnotherDatePicker. Now I get focus change events and I can bring up the AnotherDatePicker using .show and hide the soft keyboard when I want.

Thanks
Dave
 
Status
Not open for further replies.
Top