Hey John,

You've run into the focus bug (or feature) with the TimePicker. It doesn't 
update the time put in by a keyboard until it loses focus.

Try tossing a TimePicker.clearFocus() in the mix somewhere. If you use it in 
a dialog, call it on the TimePicker view when you go to dismiss the dialog 
and read the values after the clearFocus(). If it is somewhere else, you can 
also use the requestFocus() on other views to pull it away and then read the 
TimePicker.

Steven
Studio LFP
http://www.studio-lfp.com


On Monday, October 10, 2011 9:30:49 AM UTC-5, John Goche wrote:
>
>
> Hello,
>
> I am having the following problem with the timepicker. When I use
> the plus and minus signs to update the time everything works fine
> but when I use the soft keyboard I cannot read the new value from
> the time picker.
>
> Basically the problem I am having is described here:
>
>
> http://stackoverflow.com/questions/3380761/how-can-i-capture-when-time-changes-in-a-timepicker-if-the-keyboard-is-being-used
>
> However I tried the following:
>
>         <TimePicker
>           android:id="@+id/timePicker"
>           android:addStatesFromChildren="true"
>           android:layout_width="match_parent"
>           android:layout_height="wrap_content" />
>
> and the following:
>
>     this.timePicker.setOnTimeChangedListener(new OnTimeChangedListener() {
>       
>       @Override
>       public void onTimeChanged(TimePicker view, int hours, int minutes) {
>         System.out.println(hours);
>         System.out.println(minutes);
>   
>       }
>     });
>
> with no luck (I don't see the listener being called when I update the time 
> on the buttons).
> Same goes for the date picker.
>
> What am I doing wrong?
>
> I really appreciate your help on this issue,
>
> John Goche
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to