在 Android 日期选择器中禁用特定日期 [英] Disable specific dates of day in Android date picker

查看:20
本文介绍了在 Android 日期选择器中禁用特定日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I'm using the datePicker and I can disable last days of today and later days after 30 days by the following code:

DatePickerDialog datePicker = new DatePickerDialog();

             Calendar calender = Calendar.getInstance();
             long today = calender.getTimeInMillis();
             final long oneDay = 24 * 60 * 60 * 1000L;

             Date previousDays = new Date(today - 1000);
             datePicker.setMinDate(DateToCalendar(previousDays));

             Date nextMonth = new Date(today + 30 * oneDay);
             datePicker.setMaxDate(DateToCalendar(nextMonth));

If I want to disable Friday of every month, how can I do this?

解决方案

You can use this library Material Date Time Picker, here you can set an option to show specific dates, For Example:

datePicker.setSelectableDays(Calendar[] days)

And pass array of Calendar as an parameter which contains all the selectable date.

这篇关于在 Android 日期选择器中禁用特定日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆