Reputation: 8818
I am using the following code within an Activity to creat a DatePickerDialog
. I want to show the current date when 1st acitivity is called. But it is working fine. But afterwards, for some specific conditions, I want to show some other date. How to reset DatePickerDialog
date?
// the callback received when the user "sets" the date in the dialog
private DatePickerDialog.OnDateSetListener ButtonTestDateListener =
new DatePickerDialog.OnDateSetListener() {
public void onDateSet(DatePicker view, int year,
int monthOfYear, int dayOfMonth) {
mYear = year;
mMonth = monthOfYear;
mDay = dayOfMonth;
text_testdate.setText(
new StringBuilder()
// Month is 0 based so add 1
.append(formatter.format(mMonth + 1)).append("-")
.append(formatter.format(mDay)).append("-")
.append(mYear).append(" "));
}
};
@Override
protected Dialog onCreateDialog(int id) {
switch (id) {
case 0:
return new DatePickerDialog(getParent(), ButtonTestDateListener, mYear, mMonth, mDay);
}
return null;
}
.
Upvotes: 0
Views: 2779