material-calendarview icon indicating copy to clipboard operation
material-calendarview copied to clipboard

OnRangeSelectedListener and ClickListener both are not working

Open anshul90 opened this issue 5 years ago • 1 comments

Hi Team, I'm using latest version with range mode and when I'm trying to get selected dates, listeners are not working.

I'm using them as:

 @Override
public void onRangeSelected(@NonNull MaterialCalendarView widget, @NonNull List<CalendarDay> dates) {
    startDateTextView.setText(FORMATTER.format(widget.getSelectedDates().get(0).getDate()) + "");
    endDateTextView.setText(FORMATTER.format(widget.getSelectedDates().get(widget.getSelectedDates().size() - 1).getDate()) + "");
   }

@OnClick(R.id.calendarView)
public void getAndSetDates(View view) {
    if (endDateFlag) {
        endDateTextView.setText(FORMATTER.format(calendarView.getSelectedDates().get(calendarView.getSelectedDates().size() - 1).getDate()));
    } else {
        startDateTextView.setText(FORMATTER.format(calendarView.getSelectedDates().get(0).getDate()));
    }
  }

I tried to debug and found they're not getting called. Can you please check and update the issue?

Thanks, Anshul

anshul90 avatar Sep 20 '19 11:09 anshul90

You need to apply widget.setOnRangeSelectedListener(this) in onCreate of an activity to activate listener.

NsAveek avatar Oct 01 '20 04:10 NsAveek