Is there any way to detect month change in android calendar view(i.e. when user changes calendar to another month)

后端 未结 1 1060
谎友^
谎友^ 2021-02-05 18:03

I want to get month shown in calendar view and i cant figure it out. i tried

calendarView.setOnDateChangeListener(new CalendarView.OnDateChangeListener() {

            


        
相关标签:
1条回答
  • 2021-02-05 18:35

    I think from Android's default CalendarView you can't achieve what you want. For this you need to implement your custom calendar or any other library which provides this implementation or provides listeners or gestures for swiping between months. Refer this link if it helps you: Material-CalendeView

    And this is the sample code:

     MaterialCalendarView calendarView = new MaterialCalendarView(getActivity());
     calendarView.setOnMonthChangedListener(new OnMonthChangedListener() {
         @Override
         public void onMonthChanged(MaterialCalendarView widget, CalendarDay date) {
                //Do something like this
                Date date1 = date.getDate();
         }
     });
    

    Hope it helps you.

    0 讨论(0)
提交回复
热议问题