Android的自定义日历视图禁用特定日期

Android的自定义日历视图禁用特定日期

本文介绍了Android的自定义日历视图禁用特定日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新到Android开发,并开始开发一个预订应用程序。有一个日历视图,我想禁用该日历预约日期。我发现禁用功能是不是有在Android的默认日历。所以请你帮我找到一个很好的自定义日历视图,可以禁用特定的日期。我需要资源或库。谢谢!

i'm new to android developing and started to develop an booking app. There is a calendar view and i want to disable booked dates in that calendar. I found out that disabling feature is not there in android default calendar. so could you please help me to find a good custom calendar view that can disable specific dates. I need a resource or a library. Thank you!

推荐答案

在布局XML包括CalendarPickerView。

Include CalendarPickerView in your layout XML.

<com.squareup.timessquare.CalendarPickerView
android:id="@+id/calendar_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>

在你的活动/对话框的OnCreate或片段的onCreateView,初始化了一系列有效的日期,以及当前选定日期的看法。

In the onCreate of your activity/dialog or the onCreateView of your fragment, initialize the view with a range of valid dates as well as the currently selected date.

Calendar nextYear = Calendar.getInstance();
nextYear.add(Calendar.YEAR, 1);

CalendarPickerView calendar = (CalendarPickerView) findViewById(R.id.calendar_view);
Date today = new Date();
calendar.init(today, nextYear.getTime()).withSelectedDate(today);

github上链路 https://github.com/square/android-times-square

github link- https://github.com/square/android-times-square

这篇关于Android的自定义日历视图禁用特定日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!