Code example for DatePickerDialog

Methods: setButton, setCancelable, setCanceledOnTouchOutside

0
        // WORKAROUND Bug in JB prevents this standard way of working since the cancel/dismiss behaviour 
        // is broken, using workaround with custom buttons and handlers for accepting date. For more information 
        // see Bug 2 in header. 
        // return new DatePickerDialog(getActivity(), callBack, year, month, day); 
 
        DatePickerDialog picker = new DatePickerDialog(getActivity(), null, // instead of a listener we implement our
                                                                            // own buttons due to the bug 
                year, month, day);
        picker.setCancelable(true);
        picker.setCanceledOnTouchOutside(true);
        picker.setButton(DialogInterface.BUTTON_POSITIVE, getString(android.R.string.ok), acceptDateListener);
        picker.setButton(DialogInterface.BUTTON_NEGATIVE, getString(android.R.string.cancel), new DialogInterface.OnClickListener()
        { 
            @Override 
            public void onClick(DialogInterface dialog, int which)
            { /* do nothing */ 
            } 
        }); 
        return picker;
    }