如果“Soft”设置为 TimePicker,我如何捕获时间变化?正在使用键盘?

发布于 2024-09-14 07:50:48 字数 355 浏览 3 评论 0原文

继续以下链接中提到的问题:

如果正在使用键盘,如何捕获 TimePicker 中的时间变化?

我可以解决该问题,但它仅在您使用实际键盘时有效。如果您使用软键盘,我将无法使用它。

我正在使用 1.6 版本的框架进行编程。

任何帮助将不胜感激。

PS:事实上,我到处寻找答案但未能找到它,这告诉我这一定是非常简单或非常复杂。帮助?!

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?

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 appreciated.

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?!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

岁月苍老的讽刺 2024-09-21 07:50:49

参考 Cody 的评论,您需要在对话框关闭时从 TimePicker 中删除焦点。

您可以使用它,其中 tp 是 TimePicker 实例:

   public void onDialogClosed(boolean positiveResult) {
   tp.clearFocus();

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

You can use this, where tp is the TimePicker instance:

   public void onDialogClosed(boolean positiveResult) {
   tp.clearFocus();
乖不如嘢 2024-09-21 07:50:49

我也有同样的问题。如果我使用 TimePickerDialog 就没有问题。
对于在 DialogPreference 中使用 TimePicker,这是我做过的最糟糕的解决方法,沿着 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;

这样我可以直接访问输入的文本 - 但应该有更好的方法来管理键盘输入...

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...

得不到的就毁灭 2024-09-21 07:50:49

这对我有用:
我发现这个问题只是一个问题,具体取决于您使用的设备。
我有一个三星时刻,所以在其他设备(显然不是全部)和模拟器中进行测试后,我发现这只发生在我的手机上。

以下链接帮助我解决了我的问题。我希望它能帮助你...

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

非常高兴!

西蒙尼

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文