I have a widget that is a TimePicker that retrieves the time stored in a field in a database.
The fact is that when a user changes the time value in widgets, this is not stored in the database.
So, I came across the setOnTimeChangedListener method, which works like a charm if you only use the plus and minus signs in widgets. It does not commit changes if you use a keyword.
Here is my code:
pickedTime.setOnTimeChangedListener(new TimePicker.OnTimeChangedListener() { public void onTimeChanged(TimePicker arg0, int arg1, int arg2) { System.out.println("What time is it? " + String.valueOf(arg0.getCurrentHour()) + ":" + String.valueOf(arg0.getCurrentMinute())); } });
I also tried unsuccessfully:
selectedTime.setOnFocusChangeListener and selectedTime.setOnKeyListener .
android timepicker
monn3t
source share