CalendarDatePickerDialogFragment

CalendarDatePickerDialogFragment

我正在使用更好的选择器库(here's the link)在应用程序中选择日期。我想对选择器设置限制,以使最大日期是今天的日期,最小日期不超过一年前。这是显示CalendarDatePickerDialogFragment对话框的代码;

private void showDateDialog() {
    FragmentManager fm = getSupportFragmentManager();
    DateTime now = DateTime.now();
    CalendarDatePickerDialogFragment calendarDatePickerDialogFragment = CalendarDatePickerDialogFragment
            .newInstance(this, now.getYear(), now.getMonthOfYear() - 1,
                    now.getDayOfMonth());
    calendarDatePickerDialogFragment.show(fm, FRAG_TAG_DATE_PICKER);
}

最佳答案

使用calendarDatePickerDialogFragment.setDateRange(@Nullable CalendarDay startDate, @Nullable CalendarDay endDate)

关于java - 将日期限制设置为CalendarDatePickerDialogFragment Android,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/34978965/

10-08 23:36