Home » Android » java – CalendarView Android Help

java – CalendarView Android Help

Posted by: admin May 14, 2020 Leave a comment


I am trying to display a calendar in my view layout using the CalendarView and highlight/put markers on certain event dates(as per user input) which I can then click for details on that event. I don’t want to redirect to a different online calendar… rather, I just need to use a built in offline one.

How to&Answers:

First of all, after putting the CalendarView in the XML file, you need to announce it in the code when ever you might use it, for example in the MainActivity Class:

public void onCreate(Bundle savedInstanceState) 

     final CalendarView calView = (CalendarView) findViewById(R.id.calView);
     // then use it. for Exapmle:
     Date tmpDate = new Date(calView.getDate());
     // and so on.....

Is thsthelpfull to you?


Its little bit tricky.You can create your own calender view by drawing a gridView on a dialoge or a gridview on a layout (according to your requirement) and render all the dates on the that grid.You need to manually handle start date logic.i.e. from which item of the grid to start showing you date.an on that grid you can draw your marker easily.