Android日历选择控件DatePickerDialog只显示年月

来源:互联网 发布:中国网络舆论环境 编辑:程序博客网 时间:2024/05/17 02:41
public final class YearMonthDatePickerDialog extends DatePickerDialog {public YearMonthDatePickerDialog(Context context, int theme, OnDateSetListener callBack,int year, int monthOfYear, int dayOfMonth) {super(context, DatePickerDialog.THEME_DEVICE_DEFAULT_LIGHT, callBack, year, monthOfYear, dayOfMonth);setTitle(year + "年" + (monthOfYear + 1) + "月");((ViewGroup)((ViewGroup)(getDatePicker().getChildAt(0))).getChildAt(0)).getChildAt(2).setVisibility(View.GONE);}public YearMonthDatePickerDialog(Context context, OnDateSetListener callBack, int year,int monthOfYear, int dayOfMonth) {super(context, callBack, year, monthOfYear, dayOfMonth);}@Overridepublic void onDateChanged(DatePicker view, int year, int month, int day) {super.onDateChanged(view, year, month, day);setTitle(year + "年" + (month + 1) + "月");}}

0 0
原创粉丝点击