i have the DatePicker on my mainActivity.xml that the user will be able to simply use the + and - to change date. How can i get the date from this without using a dialog. Meaning the user will just adjust the date using the + and - for day month year and then when the user clicks the ADD button, it will pull the date that the user set.
Related
I am trying to make a calendar date picker dialog pop-up with a condition. User selects month and year at first. Hence, DatePickerDialog pop-up will show with minimum 28 days (for February only) and maximum 31days (for January, March, May, …, December). User is able to pick particular date in a previously selected month of the year. Thus, those dates on which user gave attendance are set enabled, rest dates are set disabled. Now, there may be a situation that user was absent for the whole month. I want to show all the dates set disabled in the calendar for that particular month of the year. I was looking at the documentation that there were methods called setSelectableDays(Calendar[] days) and setDisabledDays(Calendar[] days), both takes #NonNull array of calendar objects to enable and disable dates repectively.
So, for this case if there was no attendance date for a particular month, I tried to make a absentDates array of calendar and passed it to the second method i.e. setDisabledDays(Calendar[] days). But, it not showing anything. I tried and checked that except one day in a specific month, I can disable rest days, not all the dates at once (an image is attached of that). I want all the dates disabled in the DatePickerDialog pop-up.
If you use the official MaterialDatePicker you can implement your own DateValidator to enable/disable days and setting it to the CalendarConstraints object before building the dialog with MaterialDatePicker.Builder().datePicker().setCalendarConstraints(contraints)
You can find a sample implementation here for DateValidatorPointForward.
Documentation: https://material.io/components/date-pickers/android#using-date-pickers
I want to disable all previous dates in one date picker while i select a date in another date picker. Please don't put answer to disable all previous dates from current date. I want from selected date, not from current date.
Such as i selected 22Dec on first date picker, Now in second date picker, all previous dates from 22Dec should be disable.
I am working on date picker dialog. I want to select a date from the disabled dates which is after setting maxDate and minDate.
I gone through the following links which is suggested to disabling or avoiding selection of disabled date.
Link 1 and
Link 2
How could I achieve the scenario ? Need help on this.
I need to include a date with time in a textbox in 'yyyy-mm-dd hh:ii:ss format' using a date and time picker from a single dialog box (without using different dialog box for date and time picker).
Take a look here how to show dialog to pick date and time togather?
And alternate solutions are :
Date slider
Date time picker
Date Time Picker
And for formatting to show date and time is your own and easy task, I think now you can do it.
I am basically using a datetime control in my application.
Wherein on a click event i am initiating datetime dialog.
In another scenario, i want to move current date, to next day, or previous day.
I don't want the dialogbox of date time control to be displayed.
Is it possible??
The DatePicker and TimePicker controls are available as widgets for you to use in your layouts or code.
You can then build the next day / previous day functionality yourself by setting the date / time of those controls.