How can I capture when the time in TimePicker changes if a soft keyboard is used?

Continuing the question mentioned in the following link:

How can I capture when time changes in TimePicker if a keyboard is in use?

I could solve the problem, but it only works when using a real keyboard. If you use a soft keyboard, I cannot get it to work.

I am programming version 1.6 in version 1.6.

Any help would be greatly appreciated.

PS: The fact that I searched everywhere for an answer and could not find it tells me that it should be so simple or very difficult. Help?!

+6
android android-softkeyboard timepicker android-timepicker
source share
3 answers

I have the same problem. If I use TimePickerDialog, no problem. To use TimePicker in DialogPreference, this is a WORST workaround that I have ever made going down the TimePicker view hierarchy:

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; 

That way, I could access the direct text that was entered, but MUST be the best way to control keyboard input ...

+1
source share

Referring to Cody's comment, you need to remove focus from TimePicker when the dialog is closed.

You can use this where tp is an instance of TimePicker:

  public void onDialogClosed(boolean positiveResult) { tp.clearFocus(); 
+1
source share

This is what worked for me: I found out that this problem is only a problem depending on the device you are working with. I have Samsung Moment, so after testing on other devices (obviously not all) and emulators, I found out that this only happens with my phone.

The following link helped me solve my problem. Hope this helps you ...

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

N-Joy!

Simmone

0
source share

All Articles