Calling the date time , without initiating the dialog box of Datetime control - android

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.

Related

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

Android CalendarView how to detect Month change

I need to search my database basing the query on the month returned from a CalendarView. My problem is that onSelectedDayChange() event fires only when clicking, actually selecting a date not when the month is changed by swiping CalendarView.
How to set up something like "onSelectedMonthChange"?
You can't do it with the Android CalendarView. Look at this thread.
If you want to do it, you will have to make custom CalendarView class which will extend CalendarView and implement onGestureListener. Keep a variable curMonth to keep account of your month. Whenever swipe left/right happen, update your month variable accordingly.
if you want to show next and previous months in your calendar based on some click event, then you can do it as:
Calendar c = Calendar.getInstance();
//for next month
btnNext.onClick(){
c.add(Calendar.MONTH,1);
}
//previous month
btnPrevious.onClick(){
c.add(Calendar.MONTH,-1);
}

Setting Reminder/trigger alarm on user defined date and time

I have trouble implementing Reminder for my app.i did research but couldnt find proper solution.
what i want is:
i am developing an android app which has one feature to remind users about the selected event 30 min before event start.
i will be displaying the date and time of the event in textview,on click of reminder button reminder will set 30min before event.
how can i proceed to implement this.
Note: i dont want to use date/time picker, specific date and time will be taken directly from text view which i will display.
Any suggestion/links with logic please help.
if any one can help dn please tell me the logic to add future,date + hours + minutes to current time to set alarm(date and time will be taken from textview)

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

Getting date from DatePicker without using Dialog

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.

Categories

Resources