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


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

Query/Feedback


Your Email Id  
 
Subject 
 
Query/FeedbackCharacters remaining 250