Disable selected date in DatePickerDialog

0

Hello, guys, how are you? I wonder if it is possible, via the DatePickerDialog, to disable dates that users have chosen? Type, users choose a date in the datepicker that can no longer appear to other users, such as in hairdressing salons, which may not have the same vacancy for two people. I've even gone as far as creating the DatePickerDialog, however, I do not know how to disable these dates after being picked by users.

 diaAgendamento= (TextView) findViewById(R.id.textViewDataInicial);
    diaAgendamento.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Calendar calendar = Calendar.getInstance();
            int dia = calendar.get(Calendar.DAY_OF_MONTH);
            int mes = calendar.get(Calendar.MONTH);
            int ano = calendar.get(Calendar.YEAR);

            DatePickerDialog dialog = new DatePickerDialog(MainActivity.this, android.R.style.Theme_Holo_Dialog_MinWidth, datePicker, dia, mes, ano);
            dialog.show();
        }
    });
    datePicker = new DatePickerDialog.OnDateSetListener() {
        @Override
        public void onDateSet(DatePicker view, int year, int month, int dayOfMonth) {
            month = month + 1;
            String date = dayOfMonth + "/" + month + "/" + year;
            diaAgendamento.setText(date);
        }
    };
    
asked by anonymous 21.12.2017 / 18:49

1 answer

1

Try using this library Material Date Time Picker , you can choose an option to show specific dates. / p>

Example

datePicker.setSelectableDays(Calendar[] days)

Passing a array of Calendar as a parameter that contains all the dates that can be selected.

    
21.12.2017 / 18:57