简体   繁体   中英

CalendarView Android Help

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.

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) 
{
     super.onCreate(savedInstanceState);        
     setContentView(R.layout.main);

     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.ie from which item of the grid to start showing you date.an on that grid you can draw your marker easily.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM