Code example for DatePickerDialog

Methods: setButtongetDatePicker, setCancelable, setCanceledOnTouchOutside

0
	@Override 
	public Dialog onCreateDialog(Bundle savedInstanceState) {	
		long startDate = getArguments().getLong("startDate");
		Calendar _startDate = Calendar.getInstance();
		_startDate.setTimeInMillis(startDate);
		DatePickerDialog picker = new DatePickerDialog(getActivity(), 
				null,  
				_startDate.get(Calendar.YEAR), 
				_startDate.get(Calendar.MONTH), 
				_startDate.get(Calendar.DAY_OF_MONTH));
		picker.setCancelable(true);
		picker.setCanceledOnTouchOutside(true);
		 
		Calendar minDate = Calendar.getInstance();
		minDate.set(2013, 0, 19, 0, 0, 0);
		Calendar maxDate = Calendar.getInstance();
		maxDate.set(2013, 3, 27, 23, 59, 59);
		 
		picker.getDatePicker().setMinDate(minDate.getTimeInMillis());
		picker.getDatePicker().setMaxDate(maxDate.getTimeInMillis());
		picker.setButton(DialogInterface.BUTTON_POSITIVE, "OK",
				new DialogInterface.OnClickListener() {
			public void onClick(DialogInterface dialog, int which) {
				eventListener.onDialogPositiveClick(DatePickerFragment.this);		            	
			} 
		}); 
		picker.setButton(DialogInterface.BUTTON_NEUTRAL, "Today", 
				new DialogInterface.OnClickListener() {
			public void onClick(DialogInterface dialog, int which) {
				eventListener.onDialogNeutralClick(DatePickerFragment.this);
			} 
		});