Domanda

Is there anyway I can retrive the date from a CalendarView and use just the date information(not the visual part) in another Activity ?

È stato utile?

Soluzione

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);
}
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top