Material-calendarview: Programmatically move calendar view to certain date (either in the future or past)

Created on 4 May 2016  路  5Comments  路  Source: prolificinteractive/material-calendarview

Is there a method that can programmatically move the calendar to a certain date? This would be useful when, for instance, say I am viewing December 2016 in month mode, and want to move back to May 4 (todays date) without swiping. It would be nice to build a button that would programmatically move (in swipe motion) the calendar back to today's date --just like in Google calendar.

Most helpful comment

    //selects the day
    mCalendarView.setSelectedDate(calendarDay);

    //scrolls to month (if not already viewing)
    mCalendarView.setCurrentDate(calendarDay);

All 5 comments

There is such option. I use it just like you - go back to today.
It's something like setCurrentDate, sorry for no details but I don't have my code right now.
Tomorrow I can give you 100% sure details.

Great! I just tried it, and it works! Here's the code to programmatically scroll to three months out, for example:

Calendar c = Calendar.getInstance(); c.add(Calendar.MONTH, 3); widget.setCurrentDate(CalendarDay.from(c.getTime()), true);

    //selects the day
    mCalendarView.setSelectedDate(calendarDay);

    //scrolls to month (if not already viewing)
    mCalendarView.setCurrentDate(calendarDay);

@chuks Please close the issue if resolved, thanks!

Resolved!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Xirate picture Xirate  路  5Comments

dzafiri picture dzafiri  路  3Comments

vincent-etienne picture vincent-etienne  路  7Comments

TokyoAndroid picture TokyoAndroid  路  4Comments

SamBob01 picture SamBob01  路  3Comments