使用此代码。我在我的片段活动中使用了这个日期选择器
final Calendar c = Calendar.getInstance();
mYear = c.get(Calendar.YEAR);
mMonth = c.get(Calendar.MONTH);
mDay = c.get(Calendar.DAY_OF_MONTH);
DatePickerDialog dpdFromDate = new DatePickerDialog(getActivity(), mDateSetListener, mYear, mMonth,
mDay);
dpdFromDate.show();
dpdFromDate.setButton(DialogInterface.BUTTON_NEGATIVE, "Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
if (which == DialogInterface.BUTTON_NEGATIVE) {
//et_to_date.setText("");
et_from_date.setText("");
}
}
});