从 CalenderView 禁用星期五
Disabling Fridays from a CalenderView
我在我的应用程序中使用 CalenderView,我需要从中禁用 Fridays 的选择,如果可能需要显示为灰色(不可选择)
<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;
}
});
我在我的应用程序中使用 CalenderView,我需要从中禁用 Fridays 的选择,如果可能需要显示为灰色(不可选择)
<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;
}
});