how to set title formatter in prolificinteractive material-calendarview in kotlin

Viewed 14

enter image description herei'm using this method to set my title format but when i click on next arrow button month and year not change, sep,2022 not change

  <com.prolificinteractive.materialcalendarview.MaterialCalendarView
                android:id="@+id/calendarView"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@color/white"
                app:mcv_headerTextAppearance="@color/colorTitle"
                app:layout_constraintEnd_toEndOf="parent"
                app:mcv_weekDayTextAppearance="@color/colorTitle"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent"
                android:layout_marginHorizontal="@dimen/padding_8dp"
                app:mcv_firstDayOfWeek="sunday"
                app:mcv_leftArrow="@drawable/ic_calendar_back_disable"
                app:mcv_rightArrow="@drawable/ic_calendar_next"
                app:mcv_selectionColor="@color/colorPrimaryDark"
                app:mcv_showOtherDates="none"
                />

     val pattern = "MMM,yyyy";
                val simpleDateFormat = SimpleDateFormat(pattern);
                val date = simpleDateFormat.format(Calendar.getInstance().time);
    
                calendarView.apply {
                    setTitleFormatter { format(date) }
                }
1 Answers

I'm not sure if it accept the same template as SimpleDataFormat retrieves, you can check in the docs: https://github.com/prolificinteractive/material-calendarview#major-change-in-140

Apparently you need do some like this:

 mcv.state().edit()
.setFirstDayOfWeek(Calendar.WEDNESDAY)
.setMinimumDate(CalendarDay.from(2016, 4, 3))
.setMaximumDate(CalendarDay.from(2016, 5, 12))
.setCalendarDisplayMode(CalendarMode.WEEKS)
.commit();

You may be able to change this values above, i just use them as example.

Related