将焦点设置在软键盘后面的按钮上

发布于 2024-12-09 12:19:35 字数 247 浏览 0 评论 0原文

我在这方面遇到了麻烦,根据我所做的研究,我认为这可能是 2.1 中报告的错误。我有一个页面,其中有两个数字编辑文本字段。我可以单击第一个,然后弹出软键盘...当我按“下一步”时,焦点将根据需要转到下一个编辑文本。

现在,我在此处输入一个数字并按“下一个”,尽管软键盘显示已按下下一个,但我将焦点设置到我自己的下一个按钮(实际上被软键盘隐藏)的调用不会发生。

我尝试用代码关闭键盘,但同样没有任何效果。

一如既往,任何建议将不胜感激。

I'm having trouble with this and, from the research I have done, I think it may be a reported bug in 2.1. I have a page with two edittext fields which are numeric. I can click on the first and the soft keyboard pops up ... when I press 'next' the focus goes to the next edittext as required.

Now, I enter a number here and press 'next' and, although the soft keyboard says that next has been pressed, my call to set the focus to my own next button (which is actually hidden by the soft keyboard) doesn't happen.

I have tried to close the keyboard in code but again, nothing works.

As always, any advice will be gratefully received.

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

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

发布评论

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

评论(2

我是男神闪亮亮 2024-12-16 12:19:35

我不确定这是否是一个错误...软键盘输入中出现的“下一个”选项应该仅将焦点设置到实际上是可编辑字段的下一个视图,因此不会移动到按钮。

实际上具有硬键盘和移动焦点的箭头按钮的设备应该可以工作......但据我所知这是正常行为。用户必须后按才能关闭输入,然后操作自己的下一个按钮。

有趣的是......如果层次结构中没有接下来的可编辑视图......我的软输入通常从“下一步”更改为“完成”,所以我不确定为什么你会有“下一步”选项那个那个点。

I'm not sure if this is a bug or not... the Next option that appears in soft keyboard input should only set focus to the next view that is actually an editable field, therefore would not move to a button.

Devices that actually have hard keyboards and arrow buttons that move focus should work... but as far as I know this is normal behavior. The user would have to back-press to close the input and then operate your own next button.

Interestingly enough... if there is not an editable view coming next in the hierarchy... my soft input usually changes from "Next" to "Done" so I'm not sure why you'd even have a "Next" option that that point.

江南月 2024-12-16 12:19:35

我感谢马克西姆斯的回答,他为我指明了正确的方向。

这一切都归结为可怕的“剪切和粘贴”,我们往往不会检查我们粘贴的代码。正如我上面所说,我有两个编辑字段,第一个字段中有以下 xml 代码:

 <EditText
        android:id="@+id/editnum1"
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:imeOptions="actionNext"
        android:inputType="number"
        android:digits="1234567890./-+"
        android:maxLength="12"
        android:textSize="18sp">
      </EditText>

请注意“android:imeOptions="actionNext"”行,它告诉键盘移至下一个编辑字段。当然,我(不小心)剪切并粘贴了第二个按钮的代码,因此它认为必须有另一个编辑字段可以转到。

在 xml 中删除此行后,软键盘将按要求消失。

再次感谢,

艾伦...

I thank Maximus for his answer which pointed me in the right direction.

It all boils down to the dreaded 'Cut and Paste' where we tend not to examine the code we pasted. As I said above, I have two edit fields and I have this xml code in the first:

 <EditText
        android:id="@+id/editnum1"
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:imeOptions="actionNext"
        android:inputType="number"
        android:digits="1234567890./-+"
        android:maxLength="12"
        android:textSize="18sp">
      </EditText>

Notice the line 'android:imeOptions="actionNext" ' which tells the keyboard to move to the next edit field. Of course, I (accidentally) cut and pasted this code for the second button and so it was thinking there must be another edit field to go to.

Having removed this line in the xml the soft keyboard disappears as requested.

Thanks again,

Alan ...

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