gpt4 book ai didi

android - 如何将 android datepicker 对话框的最大日期设置为当前日期?

转载 作者:行者123 更新时间:2023-11-30 02:39:07 25 4
gpt4 key购买 nike

<分区>

我是 android 的新手,尝试了所有方法来将日期选择器对话框的最大日期设置为当前日期。做了研发但没有成功。请有人帮助我。提前致谢

代码如下:

  Calendar myCalendar;
DatePickerDialog.OnDateSetListener date;

dobET = (EditText) findViewById(R.id.dobET);
myCalendar = Calendar.getInstance();

date = new DatePickerDialog.OnDateSetListener() {

@Override
public void onDateSet(DatePicker view, int year, int monthOfYear,
int dayOfMonth) {
// TODO Auto-generated method stub
myCalendar.set(Calendar.YEAR, year);
myCalendar.set(Calendar.MONTH, monthOfYear);
myCalendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);
updateLabel();
}
};

dobET.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View v) {
// TODO Auto-generated method stub
new DatePickerDialog(ChangeProfileActivity.this, date,
myCalendar.get(Calendar.YEAR), myCalendar
.get(Calendar.MONTH), myCalendar
.get(Calendar.DAY_OF_MONTH)).show();

}
});

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com