3
Ich verwende eine Standard-Datumsauswahl in Android, jetzt möchte ich schließen Sie das Dialogfeld nach Datum auswählen die Datumsauswahl sollte in Android ohne OK SchaltflächeNach Auswahl des Datums sollte die Datumsauswahl in Android schließen ohne OK Button
schließenprivate void updateDOB() {
String myFormat = "yyyy/MM/dd"; //In which you need put here
SimpleDateFormat sdf = new SimpleDateFormat(myFormat, Locale.US);
btnDOB.setText(sdf.format(calendar.getTime()));
tvDOB.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.colorPrimary));
}
private void selectDOB() {
DatePickerDialog.OnDateSetListener listener = new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker datePicker, int year, int month, int day) {
calendar.set(Calendar.YEAR, year);
calendar.set(Calendar.MONTH, month);
calendar.set(Calendar.DAY_OF_MONTH, day);
updateDOB();
}
};
new DatePickerDialog(ActivityAddChild.this, listener,
calendar.get(Calendar.YEAR),
calendar.get(Calendar.MONTH),
calendar.get(Calendar.DAY_OF_MONTH)).show();
}