0

How do I open a new activity when each date is clicked? I know there is an onSelectedDateChange method, but I don't know how to get it to open a new activity.

What I really want it to do is to open a different activity for each day, but I can settle for each day to share the same activity.

Is there a way to accomplish this? If so, how? Thanks

Toheeb
  • 23
  • 1
  • 5

1 Answers1

0

I don't know how to get it to open a new activity

Call startActivity() on your Activity or other Context, specifying an Intent identifying the activity that you wish to start.

Note that this is how you start any activity, not just from within this particular event callback method.

Also note that since onSelectedDayChange() is passed the CalendarView, you can call getContext() on the CalendarView to get a Context suitable for use in calling startActivity(), if you like.

What I really want it to do is to open a different activity for each day

There are an indeterminate number of days left in the universe, and you cannot have an indeterminate number of activities. Instead, pass the date to your activity via an Intent extra, and pick it up in the activity that you start up.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491