简体   繁体   中英

Android CalendarView: How to open a new activity with each date click?

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM