如何在android软键盘上使用Next按钮代替phonegap中的Go按钮

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/23823308/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 07:30:01  来源:igfitidea点击:

How to get Next button on android softkeyboard in place of Go Button in phonegap

javascriptandroidjquerycordova

提问by Deep Mehta

I am developing Phonegap application and have many inputs in application form. I am getting Go button on keyboard of android.I want to replace go button with next button. As clicking on Go button (as shown in image) submits form. In android native we can specify next button in XML but for Phonegap how to specify next button in place of go button.? Some Samsung devices have by default Next Prev button on top. By Default there is Go button. I need Next but in Phonegap

我正在开发 Phonegap 应用程序,并且在申请表中有很多输入。我在 android 的键盘上得到 Go 按钮。我想用 next 按钮替换 go 按钮。点击 Go 按钮(如图所示)提交表单。在android原生中,我们可以在XML中指定下一个按钮,但对于Phonegap如何指定下一个按钮代替go按钮。?默认情况下,某些三星设备在顶部具有 Next Prev 按钮。 默认情况下有 Go 按钮。 我需要 Next 但在 Phonegap

By Default there is Go button. I need Next but in Phonegap. is there any plugin for specifying that for android.

默认情况下有 Go 按钮。我需要 Next 但在 Phonegap 中。是否有任何插件可以指定为 android.

回答by Navneeth

Having a "Next" button instead of "Go" is not possible with Android as of now.

到目前为止,Android 无法使用“下一步”按钮而不是“开始”按钮。

Android will always display "Go" button for form input fields. "Go" is basically reflecting the same behavior as of an "Enter" button on a normal browser & keyboard. You can achieve through below code:

Android 将始终为表单输入字段显示“开始”按钮。“Go”基本上反映了与普通浏览器和键盘上的“Enter”按钮相同的行为。您可以通过以下代码实现:

if (event.keyCode == 13) {
           //Handling "Go" Button to move to next input field
       }

OR

或者

If your input fields are more, then data-dependency will be best solution. If you want to prevent users from submitting the form, you can put required validations on the form using javascript, where you can specify data-dependency inside input field with required, which helps move cursor to a particular field which you specified in data-dependency.

如果您的输入字段更多,那么数据依赖将是最佳解决方案。如果您想阻止用户提交表单,您可以使用 javascript 将所需的验证放在表单上,​​您可以在其中指定输入字段内的数据依赖项,这有助于将光标移动到您在数据依赖项中指定的特定字段.

<input type="text" id="first" data-dependency="second" />
<input type="text" id="second" data-dependency="third" />
<input type="text" id="third" />

It move focus to next fields in form until its your last field. Once last field reaches you can allow it to act as enter. So basically Go will keep moving focus to next fields until its your last field & then will submit the form.

它将焦点移到表单中的下一个字段,直到它成为您的最后一个字段。到达最后一个字段后,您可以让它充当输入。所以基本上 Go 会继续将焦点移到下一个字段,直到它是你的最后一个字段,然后将提交表单。

回答by Sathya Raj

Its been said that if have input fields without or outside the form tag means you will get next button as tab button

据说,如果输入字段没有或在表单标签之外,则意味着您将获得下一个按钮作为选项卡按钮

As far as i know there is no proper solution to get next button instead of go . There are only workarounds do it. Most common one is to capture the 'Go' button as enter key(keycode '13') in javascript and do your thing.

据我所知,没有合适的解决方案来获取 next 按钮而不是 go 。只有解决方法才能做到。最常见的一种是在javascript中将“Go”按钮捕获为输入键(keycode '13')并执行您的操作。

$('selector').on("keydown",function(event){
       if (event.keyCode == 9) {
           //you got tab i.e "NEXT" Btn
       }
       if (event.keyCode == 13) {
           //you got enter i.e "GO" Btn
       }
});

for tab button instead of enter

用于选项卡按钮而不是输入

There has been also sources that already discusses these GOVs NEXTbutton

也有消息来源已经讨论了这些GOVs NEXT按钮

回答by MAST3RMIND

You can simply use the following logic to let users focus on the next input field. This is a better approach, which I used in my one of the PhoneGap applications, as currently there are no 3rd party plugins which offer such functionality.

您可以简单地使用以下逻辑让用户专注于下一个输入字段。这是一种更好的方法,我在我的一个 PhoneGap 应用程序中使用过,因为目前没有提供此类功能的 3rd 方插件。

x$('#input1').on('keyup', function(e) {
 var mEvent = e || window.event;
 var mPressed = mEvent.keyCode || mEvent.which;
 if (mPressed == 13) {
  // On enter, go to next input field
   document.getElementById('input2').focus();
 }
return true;
});

回答by Dawson Loudon

Have you tried using the tabindexparameter on your input fields?

您是否尝试过tabindex在输入字段上使用参数?

The default action of the keyboard should be to show next if tabindexis detected.

键盘的默认操作应该是如果tabindex检测到则显示下一个。

Example:

例子:

<input name="first" tabindex="1" /> //should show next

<input name="second" tabindex="2" />  //should show next

<input name="third" tabindex="3" />  //should show go

回答by Romen

EditText android:imeOptions= "actionNext"

EditText android:imeOptions="actionNext"