Android calendar for weeks and months

1

I'm working with calendars on Android. The goal is to show the calendar for weeks and months . But the calendar I'm using only allows me to view month .

xml code

    <android.support.constraint.ConstraintLayout 
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <com.prolificinteractive.materialcalendarview.MaterialCalendarView
            xmlns:app="http://schemas.android.com/apk/res-auto"
            android:id="@+id/calendarView"
            android:layout_centerInParent = "true"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            app:mcv_showOtherDates="all"
            app:mcv_selectionColor="#00F"
            />
    </android.support.constraint.ConstraintLayout>

Activity where it is invoked

    MaterialCalendarView materialCalendarView = (MaterialCalendarView) findViewById(R.id.calendarView);
    materialCalendarView.state().edit()
            .setFirstDayOfWeek(Calendar.MONDAY)
            .setFirstDayOfWeek(Calendar.DAY_OF_WEEK)
            .setMinimumDate(CalendarDay.from(1900, 1, 1))
            .setMaximumDate(CalendarDay.from(2100, 12, 31))
            .setCalendarDisplayMode(CalendarMode.MONTHS)
            .commit();

    //quando um dos dias é selecionado
    materialCalendarView.setOnDateChangedListener(new OnDateSelectedListener() {
        @Override
        public void onDateSelected(@NonNull MaterialCalendarView widget, @NonNull CalendarDay date, boolean selected) {
            Intent intent = new Intent(getBaseContext(), ActivitySelecionado.class);
            enviarDados(intent, date);
            startActivity(intent);
        }
    });

From what I have here is it possible to configure the calendar to have a view for weeks ?

    
asked by anonymous 01.08.2017 / 12:39

1 answer

0

To " have weeks view " you need to modify the value of the method parameter setCalendarDisplayMode to CalendarMode.WEEKS .

Basically change from:

setCalendarDisplayMode(CalendarMode.MONTHS)

To:

setCalendarDisplayMode(CalendarMode.WEEKS)
    
01.08.2017 / 13:20