Question

Ok, this might sound like a silly question but I'm just surprise of it happening; it seems like when you click on a day in a CalendarView, the month given from

 onSelectedDayChange(CalendarView view, int year, int month, int dayOfMonth) {

is not the one that it could be expected, because Januar is month=0, Februar is month=1 and so on. Am I the only one getting this result? Does anyone know the reason for this behaviour?

Of course, in order to print it or do something with the month, I can just increase it, but it seems just weird... :/

Was it helpful?

Solution

No it's define like that.

From the doc :

public abstract void onSelectedDayChange (CalendarView view, int year, int month, int dayOfMonth)

Added in API level 11 Called upon change of the selected day.

Parameters
view :The view associated with this listener.
year : The year that was set.
month : The month that was set [0-11].
dayOfMonth : The day of the month that was set.

You could see it at the values defined for the constants here.

You could see here why the months constants starts from 0 to 11.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top