Articles → Android → Timepicker Dialog In Android

Timepicker Dialog In Android






Example






Picture showing the timepicker control inside the linear layout
Click to Enlarge



@Nullable
@Override
protected Dialog onCreateDialog(int id) {
    return new TimePickerDialog(EditTextDemo.this,
        new TimePickerDialog.OnTimeSetListener() {
            @Override
            public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
                TextView txtView = (TextView) findViewById(R.id.tvGetDate);

                txtView.setText(hourOfDay + ":" + minute);
            }
        }, 12, 24, true);
}




showDialog(0);



Output




Picture showing the time picker control when the screen is loaded
Click to Enlarge



Picture showing the time selected from the timepicker
Click to Enlarge


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

Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250