Android自定义日历视图禁用特定日期
我是刚刚开发android并开始开发预订应用程序。有一个日历视图,我想禁用该日历中的预订日期。我发现在Android默认日历中没有禁用功能。所以你可以帮我找到一个很好的自定义日历视图,可以禁用特定的日期。我需要一个资源或一个图书馆。谢谢!Android自定义日历视图禁用特定日期
将CalendarPickerView包含在布局XML中。
<com.squareup.timessquare.CalendarPickerView
android:id="@+id/calendar_view"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
在您的活性/对话框的onCreate或者片段的onCreateView,初始化与一系列有效的日期以及当前选择的日期的图。
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);
Thanx伙计。这将帮助我! – user2214782
欢迎伙伴:) – Gattsu
你使用过这个日历吗?有一种突出显示日期但禁用日期的方法。任何我可以做的禁用日期,以便用户不能拿起那些禁用的日子! – user2214782
i have faced the same problem using custom calendar ,
i just overridden the function of adapter
@Override
public boolean isEnabled(int position) {
if(mySet.contains(position))
return true;
else
return false;
}
then i call the function int the adapter view
isEnabled(position);
befoer that tale Hashset and add the position which is displaying the calanderview
// mysetSize=set.size();
//isEnabled(Integer.parseInt(gridvalue));
Log.d(dayView.getTag()+"------1-------"+gridvalue,"-------"+position);
} else if ((Integer.parseInt(gridvalue) < 7) && (position > 28)) {
dayView.setTextColor(Color.WHITE);
dayView.setClickable(false);
dayView.setFocusable(false);
Log.d("-------mySet------","-------"+mySet);
Log.d(mysetSize+"-------28------"+gridvalue,"-------"+position);
set.add(position);
} else {
// setting curent month's days in blue color.
dayView.setTextColor(Color.DKGRAY);
Log.d(dayView.getTag()+"-------current display post------","-------"+position);
mySet.add(position);
}
尝试这些链接:HTTP://www.androiddevelopersolutions.com/2013/05/android-calendar-sync.html HTTPS: //abinashandroid.wordpress.com/2013/07/21/how-to-create-custom-calendar-in-android/ – Srijith