I am trying to make a custom Calendar view and for that I use MonthDisplayHelper to get the days of the month and a GridView to display them.
The problem is that MonthDisplayHelper is not giving me the right days order, for example if the current date is 02.20.2012, the MonthDisplayHelper gives me the following days in this order:
Sun — Mon — Tue — Wed — Thu — Fri — Sat
31 ——–1 —— 2 —— 3——- 4 —— 5 —— 6
7 —— 8 —— 9 —— 10 —— 11 —— 12 —- 13
14 —– 15 —– 16 —–17 —– 18 —– 19 —– 20 — <= the current day here is Sat but in reality is Mon
21 —– 22 —– 23 —– 24 —– 25 —– 26 —– 27
28 —— 29 ——1 —— 2 —— 3 —— 4 —— 5
So the previous month days should start from 29(on Sunday) and end with the next month days (3 on Sat)
I get the days from the MonthDisplayHelper like this:
calendarHelper = new MonthDisplayHelper(2012, 1, Calendar.SUNDAY);
int thisDay = calendarHelper.getDayAt(rowIndex, columnIndex);
and I am incrementing the rowIndex and columnIndex each time the getView() is called like this:
if (columnIndex >= 7) {
rowIndex++;
columnIndex = -1;
}
columnIndex += 1;
It seems that the problem was the gridview adapter, when it runs it gives me the same index for two or three time in a row and only after that the index gets incremented..
I modified the increment method to do the incrementation of column and row index only if the grid index is not the same as the last given one..
I’m still wondering why the adapter is doing this strange thing.. maybe someone could tell why..
Thanks