How to use Phonegap SoftKeyboard Plugin for Android?

前端 未结 5 1525
被撕碎了的回忆
被撕碎了的回忆 2020-12-05 00:31

I am developing an Android application using Phonegap. I need to make the softkeyboard appear programatically. I am using the SoftKeyboard plugin which is found here. Can an

5条回答
  •  执念已碎
    2020-12-05 01:32

    This is how I got SoftKeyBoard working in my application.

    DroidGap Side

    • create /src/com/phonegap/plugins/SoftKeyboard with provided file SoftKeyBoard.java inside
    • add to /res/xml/plugins.xml:

      < plugin name="SoftKeyBoard" value="com.phonegap.plugins.SoftKeyboard.SoftKeyBoard" />

    /assets/www Side

    • add provided file softkeyboard.js to /assets/www/js
    • add to index.html in the head where your other javascripts are included after you have included the phonegap javascript:

      < script type="text/javascript" charset="utf-8" src="js/softkeyboard.js">

    You can then call the following if you are on device or using something like Ripple:

    window.plugins.SoftKeyBoard.show(function () {
      // success
    },function () {
      // fail
    });
    

    or something like this if you want to make sure the namespace is available, which will prevent undefined problems:

    ((((window || {}).plugins || {}).SoftKeyBoard || {}).show || function(){})();
    

    I think maybe where you went wrong was not including the js/softkeyboard.js in your head of index.html.

    Hope this helps you

提交回复
热议问题