0
J'utilise le code suivant dans une activité pour créer un DatePickerDialog
. Je veux montrer la date actuelle quand la 1ère acitivité est appelée. Mais ça fonctionne bien. Mais par la suite, pour certaines conditions spécifiques, je veux montrer une autre date. Comment réinitialiser DatePickerDialog
date?DatePickerDialog Android réinitialiser la 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;
}
.