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)
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);
String[] days = null;
DateFormatSymbols names = new DateFormatSymbols();
days = names.getWeekdays();
for (int i=1; i<8; ++i) {
system.out.println(days[i]);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.