gpt4 book ai didi

java - 从 CalenderView 禁用星期五

转载 作者:行者123 更新时间:2023-12-01 18:14:46 25 4
gpt4 key购买 nike

我在我的应用程序中使用CalenderView,我需要从中禁用星期五的选择,如果可能的话需要将其显示为灰色(不可选择)

<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;
}
});

关于java - 从 CalenderView 禁用星期五,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60397199/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com