I have a widget which is a TimePicker that retrieves the time saved in a field in a database.
Thing is that when the user changes the time value in the widget, this is not being saved in the database.
So I came across the setOnTimeChangedListener method that works like a charm, if you are only using the plus and minus signs in the widget. It does not capture the change if you are using the 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’ve also tried unsuccessfully:
pickedTime.setOnFocusChangeListener and pickedTime.setOnKeyListener methods.
As mon3t found out, the option is to set android:AddStatesFromChildren=”true” in the XML file, as:
Or you can set that by code:
I really cannot understand what is the point of the default being the way it is.