您的位置:首页 > 移动开发 > Android开发

Android日历只显示年月,只显示年

2019-08-17 15:40 2723 查看
原文链接:https://www.geek-share.com/detail/2671384043.html

public class YearPickerDialog extends DatePickerDialog {
public YearPickerDialog(Context context, OnDateSetListener callBack, int year, int monthOfYear, int dayOfMonth) {
super(context, callBack, year, monthOfYear, dayOfMonth);

// this.setTitle(year + “年” + (monthOfYear + 1) + “月”);
// ((ViewGroup) ((ViewGroup) //this.getDatePicker().getChildAt(0)).getChildAt(0)).getChildAt(1).setVisibility(View.GONE);
((ViewGroup) ((ViewGroup) this.getDatePicker().getChildAt(0)).getChildAt(0)).getChildAt(2).setVisibility(View.GONE);

}

public YearPickerDialog(Context context, int theme, OnDateSetListener listener, int year, int monthOfYear, int dayOfMonth) {
super(context, theme, listener, year, monthOfYear, dayOfMonth);

// this.setTitle(year + “年” + (monthOfYear + 1) + “月”);
// ((ViewGroup) ((ViewGroup) //this.getDatePicker().getChildAt(0)).getChildAt(0)).getChildAt(1).setVisibility(View.GONE);
((ViewGroup) ((ViewGroup) this.getDatePicker().getChildAt(0)).getChildAt(0)).getChildAt(2).setVisibility(View.GONE);
}

@Override
public void onDateChanged(DatePicker view, int year, int month, int day) {
super.onDateChanged(view, year, month, day);
this.setTitle(year + "年" );
}

}
————————————————
版权声明:本文为CSDN博主「Eric_Bang」的原创文章,遵循CC 4.0 by-sa版权协议,转载请附上原文出处链接及本声明。
原文链接:https://www.geek-share.com/detail/2671384043.html

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: