How to add Next button in Ionic soft keyboard plugin

痞子三分冷 提交于 2019-12-22 04:59:11

问题


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?


回答1:


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.




回答2:


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();
    }
  });
})



回答3:


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

cordova.plugins.Keyboard.hideKeyboardAccessoryBar(false);


来源:https://stackoverflow.com/questions/32174953/how-to-add-next-button-in-ionic-soft-keyboard-plugin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!