Android的CalendarView的显示事件事件、Android、CalendarView

2023-09-11 12:39:52 作者:仅有的自尊

我想显示使用类似的默认日历应用程序的日期不同颜色的事件日历。但我没有看到默认日历视图任何这样的API。

I want to show a calendar with events using different colors on the date similar to default Calendar application. But I don't see any such API on the default calendar view.

任何人都可以请直接与我在正确的方向如何处理呢?我应该扩展默认日历,并添加自己的功能?或者我应该使用5x5的文本框与PageViewer和片段?

Can anyone please direct me on right direction how to proceed with this? Should I extend default calendar and add my own functionality? Or should I use 5x5 text boxes with PageViewer and fragments?

推荐答案

内置的CalendarView小部件不公开更改日历单元格的颜色在月视图的能力。请参阅the来源。

The built in CalendarView widget doesn't expose the ability to change the color of the calendar cells in month view. See the source.

您可以尝试以下方法:

从CalendarView扩展和实现的OnDraw自己。你将不得不重新实现所有现有的图纸行为,包括这4种方法:

Extend from CalendarView and implement onDraw yourself. You'll have to reimplement all the existing drawing behavior, including these 4 methods:


protected void onDraw(Canvas canvas) {
    drawBackground(canvas);
    drawWeekNumbersAndDates(canvas);
    drawWeekSeparators(canvas);
    drawSelectedDateVerticalBars(canvas);
}

实现你自己CalendarView,允许自定义单元格。我建议this项目作为一个很好的开始,因为它已经支持定制单元。

Implement you own CalendarView that allows customizing cells. I suggest this project as a good place to get started, since it already supports custom cells.