How to add Next button in Ionic soft keyboard plug

2019-04-26 13:47发布

We are developing the android application using the Ionic framework.

When we click on the input text box we need to show next button instead of the return button. In the native Android API, we have options to show the next button. But in the Ionic frame work we don't have options to show the next button.

How can I add the next button in the soft keyboard when input text box field is selected?

3条回答
在下西门庆
2楼-- · 2019-04-26 14:28
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(false);//show the keyboard accessory bar with the next, previous and done buttons
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);//hide the keyboard accessory bar with the next, previous and done buttons

refer to ionic-plugin-keyboard document, these functions only support ios platform, so they have no effect on android.

查看更多
再贱就再见
3楼-- · 2019-04-26 14:29

Next button won't appear because by default, ionic projects hide it.If need to show next button,Use below line inside device ready event.

cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);

The complete code is,

.run(function($ionicPlatform) {
  $ionicPlatform.ready(function() {
    // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
    // for form inputs)
    if(window.cordova && window.cordova.plugins.Keyboard) {
      //Comment out this line if you want the next and previous buttons
      cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
    }
    if(window.StatusBar) {
      // Set the statusbar to use the default style, tweak this to
      // remove the status bar on iOS or change it to use white instead of dark colors.
      StatusBar.styleDefault();
    }
  });
})
查看更多
欢心
4楼-- · 2019-04-26 14:30

The right answer would be passing false, instead of true:

cordova.plugins.Keyboard.hideKeyboardAccessoryBar(false);
查看更多
登录 后发表回答