Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android CalendarView for Showing Events

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.

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?

like image 420
Karthik Andhamil Avatar asked May 15 '13 03:05

Karthik Andhamil


People also ask

Which method is used to get a calendar view in Android?

This article shows how to create an android application for displaying the Calendar using CalendarView. It also provides the selection of the current date and displaying the date. The setOnDateChangeListener Interface is used which provide onSelectedDayChange method.


1 Answers

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

You might try the following approaches:

  1. 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); } 
  2. 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.

like image 108
nas Avatar answered Sep 23 '22 22:09

nas