简体   繁体   中英

CalendarView into android fragment

无论如何,我可以从CalendarView检索日期,而仅在另一个Activity使用日期信息(而不是可视部分)吗?

You can make use of the getDate() method. Refer this for the API documentation. Then, you can pass this to another Activity using Intent .

EDIT

You can do something like this:

@Override
protected void onCreate(Bundle savedInstanceState) {
    Date date = null;
    CalendarView v = new CalendarView( this );
    v.setOnDateChangeListener( new CalendarView.OnDateChangeListener() {
        public void onSelectedDayChange(CalendarView view, int year, int month, int dayOfMonth) {
            date = new Date(year, month, dayOfMonth);
        }
    });
    Intent intent = new Intent(this, AnotherActivity.class);
    intent.putExtra("long date", date.getTime());       
    startActivity(intent);
}

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