在 datePickerDialog 中如何用清除按钮替换取消按钮?

In datePickerDialog how to replace the cancel button by clear button?

在 datePickerDialog 中如何用 清除按钮替换取消按钮?并在我们点击它时捕获事件?

您可以使用构建器构建自己的对话:

new DatePickerDialog.Builder(this).setNegativeButton("Clear", new DialogInterface.OnClickListener() {
    @Override
    public void onClick(DialogInterface dialog, int which) {
        // they hit the clear button
    }
});

这应该可以解决您的需求:

    DatePickerDialog datePickerDialog = new DatePickerDialog(
            this, null, 2000, 1, 1);
    datePickerDialog.setButton(android.content.DialogInterface.BUTTON_NEGATIVE,
            getString(R.string.your_text), new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    // todo on click
                }
            });
    datePickerDialog.show();