'Change DatePickerDialog's button texts

I'm having some trouble changing the text of the buttons of the dialog.

I tried to use:

setButton(int whichButton,
          CharSequence text,
          DialogInterface.OnClickListener listener)

and

setButton(int whichButton, CharSequence text, Message msg)

But I could not figure out what to put as the third parameter. I could pass a new OnClickListener, but I would like to use the callback DatePickerDialog.OnDateSetListener.

I guess when I set a new Listener to the Button the DateSetListener won't ne called anymore?



Solution 1:[1]

        val now = Calendar.getInstance()

        val datePickerDialog = DatePickerDialog.newInstance(
            this,
            now.get(Calendar.YEAR),
            now.get(Calendar.MONTH),
            now.get(Calendar.DAY_OF_MONTH)
        )

        datePickerDialog.setOkText("set apply button text")
        datePickerDialog.setCancelText("set cancel button text")

Solution 2:[2]

$('input[name="dates2"]').daterangepicker({
    locale: {
       cancelLabel: 'Clear',
       applyLabel:'Change'
      }

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Atakan Akar
Solution 2 vikas pandey