1
votes

I am using CalendarPickerView to select multiple dates from a calendar. I am able to make the calendar but what happening is, I am only able to see one month of the calendar (current month in my case). There are no more months visible. I don't understand the issue. I have tried multiple pieces of code but I still see only one month of the calendar. How do I show to the user all the months of the year range(1 year) that I have provided?

The screenshot:

enter image description here

Layout:

 <com.squareup.timessquare.CalendarPickerView
      android:id="@+id/calendar_view"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:scrollbarStyle="outsideOverlay"
      android:clipToPadding="false"
      android:background="#FFFFFF"
      android:layout_alignParentTop="true"
      android:layout_above="@+id/btn_show_dates"/>

Code in OnCreate of Activity:

final CalendarPickerView calendar_view = 
findViewById(R.id.calendar_view);
Calendar nextYear = Calendar.getInstance();
nextYear.add(Calendar.YEAR, 1);
Date today = new Date();
calendar_view
    .init(today, nextYear.getTime())
    .inMode(CalendarPickerView.SelectionMode.MULTIPLE)
    .withSelectedDate(today);

I added the layout in a ScrollView also, as I thought, it is some visibility issue, but nothing works.

1
This is a fairly large control so it is wise to give it ample space in your layout. On small devices it is recommended to use a dialog, full-screen fragment, or dedicated activity. From its documentation.Jay
I made visibility of all other components on the activity to be gone, still no success!Yesha
Adding the calendar layout in a dialog box worked. Thanks!Yesha

1 Answers

0
votes

I visited com.squareup.timessquare.CalendarPickerView's Github site and I see the following in the description of the page:

The default mode of the view is to have one selectable date. If you want the user to be able to select multiple dates or a date range, use the inMode() method:

calendar.init(today, nextYear.getTime())
    .inMode(RANGE);

So please try RANGE.

You can see the CalendarPickerView class from here.

Please let me know if you can solve your problem or not. I did not have chance to try your code and the possible solution code.

Have a nice day!

EDIT

Both RANGE and MULTIPLE seems working. However, please remove <ScrollView> and try againg. I tried now and it worked! :)