简体   繁体   中英

Disable the past date in android lollipop?

我正在尝试使用此链接的日期选择器 ,但无法解决有关在android中禁用过去的日期选择的问题

Calendar c = Calendar.getInstance();
int mYear;
        int mMonth;
        int mDay;
mYear = c.get(Calendar.YEAR);

            mMonth = c.get(Calendar.MONTH);

            mDay = c.get(Calendar.DAY_OF_MONTH);


final DatePickerDialog datePickerDialog = new DatePickerDialog(this, new DatePickerDialog.OnDateSetListener() {

            @Override
            public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
                String dateOfBirth1 = dayOfMonth + "-" + (monthOfYear + 1) + "-" + year;
                dobButton.setText(dateOfBirth1);

            }
        }, mYear, mMonth, mDay);

        Calendar minDate = Calendar.getInstance();
        minDate.set(mYear1, mMonth1, mDay1);
        datePickerDialog.getDatePicker().setMinDate(minDate.getTimeInMillis());

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM