code: private OnClickListener createDialogPreferenceClickListener() {
          return new OnClickListener() {
  
              @Override
              public void onClick(final DialogInterface dialog, final int which) {
                  String button = getString(
                          which == DialogInterface.BUTTON_POSITIVE ? android.R.string.ok :
                                  android.R.string.cancel);
                  String text = String.format(getString(R.string.dialog_dismissed_toast), button);
                  Toast.makeText(getActivity(), text, Toast.LENGTH_SHORT).show();
              }
  
          };
      }
docs: Creates and returns a listener, which allows to show a toast, when a button of the {@link
  DialogPreference}'s dialog has been clicked.
  
  @return The listener, which has been created, as an instance of the type {@link
  OnClickListener}