是否有可能在DatePickerDialog禁用某些平日里? [英] Is it possible to disable certain weekdays in DatePickerDialog?

查看:193
本文介绍了是否有可能在DatePickerDialog禁用某些平日里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一个订阅服务,客户可以选择查看日期,一个datepicker。但是,并非每一天都是可用的。例如在周三没有交货。

I need a DatePicker for a subscription service where the customer can select view dates. But not every day is available. For example on Wednesdays is no delivery.

是否有可能禁用特定的星期几?

Is it possible to disable specific week days?

还是我必须作出警告事后告诉他这是不可能的。

Or do I have to make an alert afterwards to tell him this is not possible.

推荐答案


的DatePicker没有星期天

相关片段:

 if (choosenDate.get(Calendar.DAY_OF_WEEK) == 
                    Calendar.SUNDAY || 
                    now.compareTo(choosenDate) < 0) {
                    dateTextView.setTextColor(
                        Color.parseColor("#ff0000")
                    );
                    ((Button) dialog.getButton(
                    AlertDialog.BUTTON_POSITIVE))
                        .setEnabled(false);
                } else {
                    dateTextView.setTextColor(
                        Color.parseColor("#000000")
                    );
                    ((Button) dialog.getButton(
                    AlertDialog.BUTTON_POSITIVE))
                        .setEnabled(true);
                }

您可以重写这一点,当然,以阻止星期三或任何其他天
一周中的。在code写的日期选择器的OnChangeListener
在示例项目的最后一个java的线条。

You can rewrite this, of course, to block Wednesdays or any other days of the week. The code was written in the OnChangeListener of the Datepicker in the last java lines of the sample project.

这篇关于是否有可能在DatePickerDialog禁用某些平日里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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