Reputation: 696
Currently, I am using this library https://github.com/Mulham-Raee/Horizontal-Calendar
The problem I am facing is that I need to show only 7 days ahead and 7 days back from the current date.
Not getting how I will manage the start date and end date to achieve the logic
Thank you guys in advance
The code I have tried is,
Calendar endDate = Calendar.getInstance(); //end date
endDate.add(Calendar.MONTH, 1);
Calendar startDate = Calendar.getInstance(); //start date
startDate.add(Calendar.MONTH, -2);
final Calendar defaultDate = Calendar.getInstance();
defaultDate.add(Calendar.MONTH, -2);
horizontalCalendar = new HorizontalCalendar.Builder(this, R.id.calendarView)
.startDate(startDate.getTime())
.endDate(endDate.getTime())
.datesNumberOnScreen(5)
.dayNameFormat("EEE")
.dayNumberFormat("dd")
.monthFormat("MMM")
.showDayName(true)
.showMonthName(true)
.defaultSelectedDate(defaultDate.getTime())
.textColor(Color.LTGRAY, Color.WHITE)
.build();
Upvotes: 0
Views: 2607
Reputation: 6828
Try changing Calendar.DAY_OF_MONTH
property,
Calendar endDate = Calendar.getInstance(); // End date
endDate.add(Calendar.DAY_OF_MONTH, 7);
Calendar startDate = Calendar.getInstance(); // Start date
startDate.add(Calendar.DAY_OF_MONTH, -7);
Calendar defaultDate = Calendar.getInstance();
Upvotes: 2