### Create DatePickerDialog Instance using Factory Method Source: https://github.com/mohamad-amin/persianmaterialdatetimepicker/blob/master/README.md Instantiate TimePickerDialog or DatePickerDialog using their static newInstance() method. Provide default values and a callback. Once configured, call show() to display the dialog. ```Java PersianCalendar persianCalendar = new PersianCalendar(); DatePickerDialog datePickerDialog = DatePickerDialog.newInstance( MainActivity.this, persianCalendar.getPersianYear(), persianCalendar.getPersianMonth(), persianCalendar.getPersianDay() ); datePickerDialog.show(getFragmentManager(), "Datepickerdialog"); ``` -------------------------------- ### Theme Material Design Pickers with Custom Colors Source: https://github.com/mohamad-amin/persianmaterialdatetimepicker/blob/master/README.md Customize the appearance of the pickers by overriding the mdtp_accent_color and mdtp_accent_color_dark color resources in your project's XML. ```XML #009688 #00796b ``` -------------------------------- ### Implement OnTimeSetListener and OnDateSetListener for Picker Callbacks Source: https://github.com/mohamad-amin/persianmaterialdatetimepicker/blob/master/README.md To receive the date or time set in the picker, implement the OnTimeSetListener or OnDateSetListener interfaces. These callbacks are typically handled by the Activity or Fragment creating the pickers and use the standard Android picker API. ```Java @Override public void onTimeSet(RadialPickerLayout view, int hourOfDay, int minute) { String time = "You picked the following time: "+hourOfDay+"h"+minute; timeTextView.setText(time); } @Override public void onDateSet(DatePickerDialog view, int year, int monthOfYear, int dayOfMonth) { String date = "You picked the following date: "+dayOfMonth+"/"+(monthOfYear+1)+"/"+year; dateTextView.setText(date); } ``` -------------------------------- ### Highlight Specific Days in DatePickerDialog Source: https://github.com/mohamad-amin/persianmaterialdatetimepicker/blob/master/README.md Provide an array of PersianCalendar objects to setHighlightedDays() to render specific days in bold. The highlight color can be customized by overriding mdtp_date_picker_text_highlighted. ```APIDOC DatePickerDialog: setHighlightedDays(PersianCalendar[] days): Pass a PersianCalendar[] of days to highlight (rendered in bold). Color can be tweaked by overwriting mdtp_date_picker_text_highlighted. ``` -------------------------------- ### Handle Dismiss and Cancel Events for Pickers Source: https://github.com/mohamad-amin/persianmaterialdatetimepicker/blob/master/README.md Both TimePickerDialog and DatePickerDialog can be configured with a DialogInterface.OnDismissListener or DialogInterface.OnCancelListener to execute code when the dialog is dismissed or cancelled. ```Java timePickerDialog.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialogInterface) { Log.d("TimePicker", "Dialog was cancelled"); } }); ``` -------------------------------- ### Enable Dark Theme for TimePickerDialog Source: https://github.com/mohamad-amin/persianmaterialdatetimepicker/blob/master/README.md Set the TimePickerDialog to use a dark theme by calling the setThemeDark(true) method on its instance. ```Java timePickerDialog.setThemeDark(true); ``` -------------------------------- ### Control Picker Vibration on Selection Source: https://github.com/mohamad-amin/persianmaterialdatetimepicker/blob/master/README.md Use vibrate(boolean vibrate) to enable or disable device vibration when a selection is made in the dialogs. This setting defaults to true. ```APIDOC Picker Dialogs: vibrate(boolean vibrate): Set whether the dialogs should vibrate the device when a selection is made. Defaults to true. ``` -------------------------------- ### Enable Dark Theme for DatePickerDialog Source: https://github.com/mohamad-amin/persianmaterialdatetimepicker/blob/master/README.md Set the DatePickerDialog to use a dark theme by calling the setThemeDark(true) method on its instance. ```Java datePickerDialog.setThemeDark(true); ``` -------------------------------- ### Set Title for TimePickerDialog Source: https://github.com/mohamad-amin/persianmaterialdatetimepicker/blob/master/README.md Display a custom title at the top of the TimePickerDialog by using the setTitle(String title) method. ```APIDOC TimePickerDialog: setTitle(String title): Shows a title at the top of the TimePickerDialog ``` -------------------------------- ### Restrict Selectable Days in DatePickerDialog Source: https://github.com/mohamad-amin/persianmaterialdatetimepicker/blob/master/README.md Pass an array of PersianCalendar objects to setSelectableDays() to define the only acceptable dates for the picker. This method takes precedence over setMinDate() and setMaxDate(). ```APIDOC DatePickerDialog: setSelectableDays(PersianCalendar[] days): Pass a PersianCalendar[] to define the only acceptable dates for the picker. Takes precedence over setMinDate() and setMaxDate(). ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.