Question

With:

Calendar cal = Calendar.getInstance();
cal.setFirstDayOfWeek(Calendar.MONDAY);

you just set Monday's integer value to 0, but I want to have Monday displayed as first day (at the left end, and Sunday at the right)

Was it helpful?

Solution

Use xml parameter android:firstDayOfWeek with value from Calendar. 2 - is Monday.

    <CalendarView
    android:id="@+id/calendarView1"
    android:firstDayOfWeek="2"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_alignParentBottom="true"
    android:layout_centerHorizontal="true"
    android:layout_marginBottom="157dp" />

Or you can specify it from code

    CalendarView calendarView = findViewById(R.id.calendarView1);
    calendarView.setFirstDayOfWeek(Calendar.MONDAY);

OTHER TIPS

String[] days = null;
DateFormatSymbols names = new DateFormatSymbols();
days = names.getWeekdays();

for (int i=1; i<8; ++i) {
    system.out.println(days[i]);
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top