How to give validation to calendar - android

I'm creating a appointment booking app in android studio.
So while selecting time in time picker i want the time between 14:00pm and 16:00pm to be disabled ,similarly - the timing at night must be disabled.
&
While selecting Date , I want the previous dates to be disabled.
is it possible?

You would have to use a custom TimePickerDialog in this case, same goes to the date as well if you would need that functionality too.
See this post - Custom TimePickerDialog or use this library - MaterialDateTimePicker with material design.

Related

How to enable setCalendarViewShown or disable calendar in datepicker post API 24

I have a project where I use datepicker for the user to confirm a date
When the user selects confirm I wish to disable the datepicker so that they can't use it again
Unfortunatelly when I do something like this:
((DatePicker)findViewById(R.id.datepicker)).enabled = false;
only the spinner part gets disabled while the calendar can still be touched and used to alter the spinner
the only solution I found is using setCalendarViewShown(false) when the user confirms and then disabling the picker
unfortunatelly this seems to be deprecated so I wish to find some way to replace it
So my question is this
Is there a way to programmatically either disable ALL parts of the DatePicker or hide the calendar?
I know it can be done through xml but I wish to use it in code
Thanks in advance for any help you can provide
You can hide the datepicker with:
datepicker.setVisibility(View.INVISIBLE);
An option that you can choose to disabled all dates less one, is combine this two lines.
datepicker.setMinDate
datepicker.setMaxDate
So after the user pick one date, set the date like the min and the max of the calendar, and with this way, the user will not be able to choose a new one.
Something like:
datepicker.setMinDate(theDatePickedByUser)
datepicker.setMaxDate(theDatePickedByUser)
It should work...

does datepicker in android for year BC and AD exist

is there any datepicker in Android, which I can use for selecting dates BC and AD ?
or do I have to create my own one ?
By default datepicker in Android only goes to 1970.
You can somewhat manipulate the date though.
For help with creating a custom datepicker, you can try here.

How to select date range from CalendarView in android?

I need to select more than once date from a CalenderView of android. Can any one help me to do the same.
Example!
Let's look attached image. If we consider the calender in image as CalenderView of android I need to select all date raging from 16th to 20th.
As far as I know the CalendarView only supports selecting single dates.
I would suggest calling it twice to get the start and end dates (for the end date, you could call setMinDate() beforehand to make sure it's greater than the start date).

What User Interface Design or Layout is this

I am currently developing a reservation system application that would require the user to input date and time.
So that would mean that I would have a date picker and a time picker in mu layout file.
Upon doing so, when a user clicks the button to set Date and time of reservation the app will then start an Intent and opens another activity but as far as I see it, It would look awful if I do such so I was wonder how to do this kind of UI so that it would not be as hassle as to start and activity for a result.
You have a number of options to implement this behavior.
The official date picker dialog and time picker dialog.
Given that the use of dialogs is discouraged, try using the widgets inline with CalendarView and DatePicker if you can.
A backported version of the widgets CalendarView and DatePicker.

Android DatePicker components order

I made a custom DatePicker that extends the android DatePicker UI component. I needed this to make possible the visibility option for each DatePicker's view component(day,month and year).
I made this possible by hiding the views from DatePicker by its index.
I get the index of each component by getting the date format order like this DateFormat.getDateFormatOrder(context) , this returns a char array like {m, d, y} so I can get the order of the DatePicker components and hide them..
The problem I run into is that on some devices the DatePicker position its components by the selected locale of the user and not by the selected date format.
How can I get the DatePicker's components order? Or how I can figure out that DatePicker will position its components by locale or date format?
Note that I am developing this on Android API level 2.1++ and I would prefer not to make my own DatePicker so I can preserve the android DialogPicker UI theme.
Thank you!
And unfortunately the answer is: I had to develop my own DatePicker and now everything works fine

Categories

Resources