Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 477
Kgrover Avatar asked Jul 11 '11 05:07

Kgrover


2 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) 
{
     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?

like image 147
zaxy78 Avatar answered Oct 02 '22 04:10

zaxy78


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.

like image 44
iBAD Avatar answered Oct 02 '22 02:10

iBAD