调用
DatePickerDialog dialog = new DatePickerDialog(MainActivity.this, THEME_HOLO_LIGHT, new DatePickerDialog.OnDateSetListener() { @Override public void onDateSet(DatePicker view, int year, int month, int dayOfMonth) { //对选择的日期进行处理 }, int year,int month-1,int day); dialog.show();
THEME_HOLO_LIGHT : theme设置
请参考:http://blog.youkuaiyun.com/lckj686/article/details/19552793
修改显示的条目数:年、月、日的选择:
不显示日:DatePicker dp = findDatePicker((ViewGroup) dialog1.getWindow() .getDecorView()); if (dp != null) { View view = ((ViewGroup) ((ViewGroup) dp.getChildAt(0)) .getChildAt(0)).getChildAt(2); view.setVisibility(View.GONE); }private DatePicker findDatePicker(ViewGroup group) { if (group != null) { for (int i = 0, j = group.getChildCount(); i < j; i++) { View child = group.getChildAt(i); if (child instanceof DatePicker) { return (DatePicker) child; } else if (child instanceof ViewGroup) { DatePicker result = findDatePicker((ViewGroup) child); if (result != null) return result; } } } return null; }请参考:http://blog.youkuaiyun.com/lzt623459815/article/details/8479991