How to set a specific date in date picker in android

后端 未结 3 1228
没有蜡笔的小新
没有蜡笔的小新 2021-01-25 04:24

I tried a lot,but all doesn\'t work.

I need my date picker the date starts with september 1 2014.But it starts 1900. I set minimum date concept it disappears all past da

3条回答
  •  感情败类
    2021-01-25 05:12

    class DatePickerDialog1964 extends DatePickerDialog {
    DatePickerDialog1964(Context c) {
        super(c, null, 2013, 4, 21);
    
        @SuppressWarnings("deprecation")
        Date min = new Date(2013-1900, 4, 21);
    
        DatePicker p = getDatePicker();
        CalendarView cv = p.getCalendarView(); // should check for null
        long cur = cv.getDate();
        int d = cv.getFirstDayOfWeek();
        p.setMinDate(min.getTime());
        cv.setDate(cur + 1000L*60*60*24*40);
        cv.setFirstDayOfWeek((d + 1) % 7);
        cv.setDate(cur);
        cv.setFirstDayOfWeek(d);
    }
    

    }

    OR

    DatePickerDialog dpDialog = new DatePickerDialog(this, pDateSetListener, pYear, pMonth, pDay);
    DatePicker datePicker = dpDialog.getDatePicker();
    
    Calendar calendar = Calendar.getInstance();//get the current day
    datePicker.setMinDate(calendar.getTimeInMillis());//set the current day as the max date
    return dpDialog;
    

提交回复
热议问题