Add event to CalendarView

Cilenco picture Cilenco · Feb 24, 2014 · Viewed 32.7k times · Source

I think the question says it all: is it possible to display events in the Android default CalendarView?

I know that it is made for widgets and not for a real Calendar application but my app should not be a Calendar application. It is only a little feature in my app so I think the View is perfect for my claims. I only can't view events in it, otherwise it is perfect for me.

I read this answer and tried to overwrite the onDraw method from CalenderView:

@Override
protected void onDraw(Canvas canvas)
{
    p = new Paint();

    p.setColor(Color.RED);
    p.setStrokeWidth(10);

    super.onDraw(canvas);
    canvas.drawRect(0, 0, 100, 100, p);
}

But even this code does not work and no rectangle is displayed. The other 4 methods are private so I can't overwrite them. Any other ideas how I can solve this problem? I do not want to use a library, but if there is no other way I'm looking for something what is really near to the stock CalendarView. Or maybe I can create a calendar file which is only visible in my app and not in other calendar apps?

Answer

Mehul Joisar picture Mehul Joisar · Mar 6, 2014

You can't add events in default CalendarView. either you need to make it custom or you need to use some library.

I have used Caldroid library many times.it is easy to implement and robust.

enter image description here