erdomester
erdomester

Reputation: 11829

Android datepicker get date

I placed a datepicker on a layout to let the user select their birthday. I have used datepickerdialogs earlier by clicking on a button and bringing the dialog up. But this time the datepicker itself is on the layout and I can select a date. How can I get the date every time the user changes the day, month or the year?

enter image description here

Solution:

dpResult = (DatePicker) findViewById(R.id.dpResult);

dpResult.init(year, month, day, new OnDateChangedListener() {
    @Override
    public void onDateChanged(DatePicker view, int year, int monthOfYear,int dayOfMonth) {

           //here I got all the values I need
    }
    });

Upvotes: 0

Views: 1038

Answers (1)

AMerle
AMerle

Reputation: 4354

I guess you have to use init(int year, int monthOfYear, int dayOfMonth, DatePicker.OnDateChangedListener yourListenerHere). Did you try this ?

Upvotes: 1

Related Questions