Articles → Android → Timepicker In Android
Timepicker In Android
Purpose
Example
Click to Enlarge
TimePicker MyTimePicker = (TimePicker) findViewById(R.id.MyTimePicker);
MyTimePicker.setOnTimeChangedListener(new TimePicker.OnTimeChangedListener() {
@Override
public void onTimeChanged(TimePicker view, int hourOfDay, int minute) {
TextView txtView = (TextView) findViewById(R.id.tvGetDate);
txtView.setText(hourOfDay + ":" + minute);
}
});
Output
Click to Enlarge
Set The Hour And Minute Of Timepicker
TimePicker MyTimePicker = (TimePicker)findViewById(R.id.MyTimePicker);
MyTimePicker.setHour(13);
MyTimePicker.setMinute(22);
Click to Enlarge