Articles → Android → Datepicker dialog in android

Datepicker dialog in android






Example







Click to Enlarge



@Nullable
@Override
protected Dialog onCreateDialog(int id) {
       return new DatePickerDialog(this, new DatePickerDialog.OnDateSetListener() {
           @Override
           public void onDateSet(DatePicker view, int year, int month, int dayOfMonth) {
               TextView textView = (TextView)findViewById(R.id.tvGetDate);
               textView.setText(String.valueOf(year) +
                       "-" + String.valueOf(month) + "-" + String.valueOf(dayOfMonth));
           }
       },2019,10,31);
}




showDialog(0);



Output





Click to Enlarge




Click to Enlarge




Posted By  -  Karan Gupta
 
Posted On  -  Monday, November 25, 2019

Query/Feedback


Your Email Id  
 
Subject 
 
Query/FeedbackCharacters remaining 250