Add event to CalendarView
Solution 1
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.
Solution 2
Shameless plug. I've also written my own android CalendarView which allows you to add events, listeners, provides infinite scrolling and is a gradle project: https://github.com/SundeepK/CompactCalendarView .
![Cilenco](https://i.stack.imgur.com/WY0Zw.png?s=256&g=1)
Cilenco
Student at the university of Münster (Germany). I concentrate on Android development and efficient algorithms and data structures.
Updated on March 05, 2020Comments
-
Cilenco over 4 years
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 stockCalendarView
. Or maybe I can create a calendar file which is only visible in my app and not in other calendar apps?