I'm following the tutorial here: http://developer.android.com/guide/topics/ui/controls/pickers.html
I got things to work and the datepicker shows up. However, I am stuck on how to act on when the user sets the date.
I see they have this method:
public void onDateSet(DatePicker view, int year, int month, int day) {
// Do something with the date chosen by the user
}
But that does nothing if I put any code in it.
I'm not that familiar with Java so I'm not sure what additional code is needed in order to update a textview with the chosen date.
I did add this code:
private DatePickerDialog.OnDateSetListener mDateListener =
new DatePickerDialog.OnDateSetListener() {
public void onDateSet(DatePicker view, int year, int month, int day) {
updateDate(year, month, day);
}
};
public void updateDate(int year, int month, int day) {
TextView bdate = (TextView)findViewById(R.id.birthDate);
Date chosenDate = new Date(year, month, day);
java.text.DateFormat dateFormat = DateFormat.getDateFormat(getApplicationContext());
bdate.setText(dateFormat.format(chosenDate));
}
But that does nothing.
I did find this almost exact question: Get date from datepicker using dialogfragment
However in that solution wouldn't using (EditSessionActivity) limit the DatePickerFragment class to working with only the EditSessionActivity?