How can I add new button in date picker widget in android?

SavasCinar picture SavasCinar · Jan 3, 2012 · Viewed 11k times · Source

I want to add new button,which is clear button, to date picker widget and time picker widget in my android application. In default, these widgets have two button,set and cancel. How can I add one more button to these two button

Is it possible? If yes, can you give some example?

Thanks

Answer

undefined picture undefined · Feb 27, 2016

Just add a neutral button.

DatePickerDialog dialog = new DatePickerDialog(context, 0, callback, year, month, day);
dialog.setButton(DialogInterface.BUTTON_NEUTRAL, "Name", new DialogInterface.OnClickListener() {
    @Override
    public void onClick(DialogInterface dialog, int which) {
        //Your code
    }
});