3

I'm starting to work with CalendarView to show a calendar. This is working OK but now I would like to show some events in some specific days. I'm developing a demo so just would like to hardcode some fake events in my calendar to show the functionality, but don't know how to do it. Yeah, already had a look at de documentation. Should I use a CalendarProvider?? then how to get the id from my CalendarView??

Thanks!!!

steve_patrick
  • 735
  • 2
  • 9
  • 19
  • you can add click event when you click on a date(it is different from onClick) [**Click here...**](http://stackoverflow.com/questions/11949183/calendarview-clickable-android/11951392#comment15924112_11951392) – Atul Bhardwaj Aug 22 '12 at 07:42

1 Answers1

-1

Yes its quite easy to add events on some specific date.you can add below code in your calendar.java file and add your events for that specific date.

public Runnable calendarUpdater = new Runnable() {

    @Override
    public void run() {
        items.clear();

        // Print dates of the current week
        DateFormat df = new SimpleDateFormat("yyyy-MM-dd", Locale.US);
        String itemvalue;
        for (int i = 0; i < 7; i++) {
            itemvalue = df.format(itemmonth.getTime());
            itemmonth.add(Calendar.DATE, 1);
            items.add("2013-09-12");
            items.add("2013-10-07");
            items.add("2013-10-15");
            items.add("2013-10-20");
            items.add("2013-11-30");
            items.add("2013-11-28");

        }

        adapter.setItems(items);
        adapter.notifyDataSetChanged();
    }
};