DatePickerDialog datePicker=new DatePickerDialog(mContext, DatePickerDialog.THEME_HOLO_LIGHT,new DatePickerDialog.OnDateSetListener() { @Override public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) { ToastUtils.show(mContext,"当前选择:"+year); } }, 2019,0,0); DatePicker dp = datePicker.getDatePicker(); //隐藏月份 ((ViewGroup) ((ViewGroup) dp.getChildAt(0)).getChildAt(0)) .getChildAt(1).setVisibility(View.GONE); //隐藏日 ((ViewGroup) ((ViewGroup) dp.getChildAt(0)).getChildAt(0)) .getChildAt(2).setVisibility(View.GONE); datePicker.show();
DatePickerDialog 只显示年份/月份/日
最新推荐文章于 2024-07-29 09:34:21 发布