Select disabled date from date picker dialog android - android

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.

Related

How to Disable Current Date in MaterialDatePicker?

I am trying to integrate date selection using MaterialDatePicker. as of now, I can disable past date and future dates by using programmatically. but I am trying to achieve to disable the current date selection along with the future date. please help me. your help will be appreciated.
so for your calendarConstraints, you can do
calendarConstraints.setEnd(<Replace with today's date>)
that should disable the current date and future date

How to show Material Calendar with all disabled dates in Android datePickerDialog

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

Taking Date and Time Values from Single CustomView

I have implemented DatePicker and TimePicker in android.
Now, As we know that DatePicker prompts user to give input only for specific date, same as TimePicker prompts user to give input only for specific time. But, I require to make a single CustomView that handle to take date and time both as input from user.
How can I do this ?
Thanks in Advance.
DateTime Picker
Hope this helps...
There is a Project Sample Which has both Date And Time Picker Together.
You can find a DateTimePicker implementation here

Date picker for selecting a period of time

I need a custom date picker like this. But I need to select a period of time in my date picker.
for example I want: user open the date picker dialog, then select start day, then select end day (days between this 2 days are highlighted) then close the date picker dialog.
is there any open source library which i can use for this scenario?
or is there any way to edit this date picker to achieve this ?
I will appreciate any help.
Thank you
You can use android times square
this widget supports date ranges, but not have the same look and feel

Date Picker in Android

I want to display a date picker for selecting date of birth,so as to user restricted to choose future date.currently date picker displays all dates including future also.i want to show the dates up to current dates only.
Thanks.
I recommend the Date Picker Dialog? Then just extend it to fit your requirements.
It's some what hard to explain how to create a Date Picker. What's better is looking at the sample code from the Android API Demos which shows you how to do a Date Picket and much more. You can figure out how to download these API Demos at: http://developer.android.com/resources/samples/get.html. Good luck!
Use the setMaxDate function, and set that to the current date
Datepicker dp = (DatePicker) v.findViewById(R.id.date_picker);
// Set it to only show past dates...
dp.setMaxDate(System.currentTimeMillis());
(reference)

Categories

Resources