简体   繁体   中英

Disabling Fridays from a CalenderView

I am using a CalenderView in my app and i need to disable the selection of Fridays from it, and if possible need to show it as grey(not selectable)

<CalendarView
    android:id="@+id/simpleCalendarView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"/>
private Calendar lastSelectedCalendar = null;
private CalendarView calendarView;


calendarView = (CalendarView) findViewById(R.id.calendarView);
lastSelectedCalendar = Calendar.getInstance();
calendarView.setMinDate(lastSelectedCalendar.getTimeInMillis() - 1000);
calendarView.setOnDateChangeListener(new CalendarView.OnDateChangeListener() {

@Override
public void onSelectedDayChange(CalendarView view, int year, int month, int dayOfMonth) {
    Calendar checkCalendar = Calendar.getInstance();
    checkCalendar.set(year, month, dayOfMonth);
    if(checkCalendar.equals(lastSelectedCalendar))
        return;
    if(checkCalendar.get(Calendar.DAY_OF_WEEK) == Calendar.FRIDAY)
        calendarView.setDate(lastSelectedCalendar.getTimeInMillis());
    else
        lastSelectedCalendar = checkCalendar;
}
});

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM