Android Question DatePickerDialog (java.util.calendar)

Pedro Caldeira

Active Member
Licensed User
Longtime User
Hello All,
I am trying to restraint the period that the user has to pick some days and I am using the DatePickerDialog.
However, to set minDate, MaxDate and SelectableDays I must enter the values in java.util.calendar format.
How do I do that ?

B4X:
Dim today As Long = DateTime.Now
Dim DP As DatePickerDialog
DP.Initialize("Date_From_Picker",DateTime.GetYear(today),DateTime.GetMonth(today), DateTime.GetDayOfMonth(today))
DP.MinDate = ??
DP.MaxDate = ??
DP.show("Date_From_Picker")
 

Pedro Caldeira

Active Member
Licensed User
Longtime User
You can do it easily with B4XDateTemplate + B4XDialog.

I know, but:
I need to restraint the days that the user can pick
I want the dialog to stay in screen until the user presses OK
Can I do that with B4XDateTemplate + B4XDialog ?
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
I want the dialog to stay in screen until the user presses OK
Can I do that with B4XDateTemplate + B4XDialog ?
Yes. I was able to do it by modifying the class module B4XDateTemplate in the XUI Views library and renaming it to say: myB4XDateTemplate and reference the class module name . Once you do that, you COMMENT a line that starts with Hide. in the class That is how it worked for me. But, Erel may have a simpler method without modifying the class as he always does.
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
How do I access this class ?
1. Make a copy of the internal library: XUI Views.b4xlib
2. Change its extension to zip
3. Unzip it somewhere on your computer.
4. You will see: B4XDateTemplate.bas
5. Change its name to: myB4XDateTemplate.bas
6. Edit myB4XDateTemplate.bas by commenting the line : Hide., then save it.
7. Use it as your class module and refer to it in your code. Do not save it back to XUI VIews.b4xlib and do not modify: XUI VIews.b4xlib
 
Upvote 0

Pedro Caldeira

Active Member
Licensed User
Longtime User
1. Make a copy of the internal library: XUI Views.b4xlib
2. Change its extension to zip
3. Unzip it somewhere on your computer.
4. You will see: B4XDateTemplate.bas
5. Change its name to: myB4XDateTemplate.bas
6. Edit myB4XDateTemplate.bas by commenting the line : Hide., then save it.
7. Use it as your class module and refer to it in your code. Do not save it back to XUI VIews.b4xlib and do not modify: XUI VIews.b4xlib
Thanks
 
Upvote 0
Top