views:

32

answers:

3

Continuing with the question referred in the following link:

[How can I capture when time changes in a TimePicker if the keyboard is being used?][1]

[1]: http://stackoverflow.com/questions/3380761/how-can-i-capture-when-time-changes-in-a-timepicker-if-the-keyboard-is-being-used/"How can I capture when time changes in a TimePicker if the keyboard is being used?"

I could solve the problem but it only works when you use the actual keyboard. If you use the soft keyboard I can't get it to work.

I am programming in 1.6 version of the framework.

Any help will be much appreciate,

Monn3t

PS: The fact that I've search everywhere for the answer and have not been able to find it tells me that this must be so very simple or very much complicated. Help?!

A: 

I'm having the same problem ... I hope that anyone can help?

Franklin
A: 

This is what worked for me: I found out that this issue is only an issue depending on the device your working with. I have a Samsung Moment, so after testing in other devices (obviously not all of them) and emulators I found out it was only happening with my phone.

The following link helped me solve my problem. I hope it helps you...

http://blog.xiaad.com/2010/03/android-datepicker-years-before-2000.html

N-Joy!

Simmone

monn3t
A: 

I've got the same problem. If I use TimePickerDialog there's no problem. For using TimePicker in a DialogPreference, this is the WORST workaround I've ever made, going down the view hierarchy of the TimePicker:

ViewGroup v = (ViewGroup) timePicker.getChildAt(0);
ViewGroup numberPicker1 = (ViewGroup) v.getChildAt(0);
ViewGroup numberPicker2 = (ViewGroup) v.getChildAt(1);

String hours = ((EditText) numberPicker1.getChildAt(1)).getText().toString();
String mins = ((EditText) numberPicker2.getChildAt(1)).getText().toString();

String selectedTime = hours+":"+mins;

This way I could access the text directly which was typed in - but there SHOULD be a better way to manage keyboard inputs...

cody
Cody... may be is the device. I checked with the G1 and it was working fine, but it worked in a different way in my Samsung Moment. Have you checked if the behavior is the same in other devices?
monn3t
No, I didn't, I only know that my timepicker didn't behave as expected on an emulator. Perhaps you are right. Anyway, if it's not working properly on all target devices, there has to be a solution. You can't simply attach an OnTimeSetListener to a TimePicker, like for TimePickerDialog. It seems the OnTimeChangedListener only takes care of a manual input, if the respective EditText looses focus before the OK button is clicked. If it still has focus when clicking OK, the OnTimeChangedListener doesn't notice it.
cody