I have an EditView
in which I am trying to bind DatePickerDialog
. Its working well with the api 19. but when tested on api version 25 Marshmallow the calendar becomes white and when selected some date the EditView
is not populated as well i.e I am unable to set date in Marshmallow.
Code:
warrantyExpEt.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
new DatePickerDialog(getContext(), date, myCalendar
.get(Calendar.YEAR), myCalendar.get(Calendar.MONTH),
myCalendar.get(Calendar.DAY_OF_MONTH)).show();
}
});
final DatePickerDialog.OnDateSetListener date = new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year, int monthOfYear,
int dayOfMonth) {
// TODO Auto-generated method stub
myCalendar.set(Calendar.YEAR, year);
myCalendar.set(Calendar.MONTH, monthOfYear);
myCalendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);
updateLabel();
}
};
private void updateLabel() {
String myFormat = "yyyy-MM-dd";
SimpleDateFormat sdf = new SimpleDateFormat(myFormat, Locale.US);
warrantyExpEt.setText(sdf.format(myCalendar.getTime()));
}