Is there anyway I can retrive the date from a CalendarView and use just the date information(not the visual part) in another 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);
}
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top