Hodaya Shalom
Hodaya Shalom

Reputation: 4417

Hiding the android keyboard does not work

I'm building an application of Html5 + PhoneGap for Android.

I want that when a function call the Android keyboard be hidden.

I tried to do it in the following way:

function HideKeyboard() {
        alert('HideKeyboard');
        plugins.SoftKeyBoard.hide(function () {
              alert('s');
            }, function () {
             alert('f');
           });
        }

It did not work! There is another way?

the alert 'HideKeyboard' appears, but other messages do not appear

Here my plugin:

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

Thank you ..

Upvotes: 1

Views: 847

Answers (1)

dlamblin
dlamblin

Reputation: 45321

Did you:

  1. Create /src/org/apache/cordova/plugins with SoftKeyBoard.java in it
  2. Add the plugin definition to /res/xml/plugins.xml:

    <plugin name="SoftKeyBoard"
           value="org.apache.cordova.plugins.SoftKeyBoard" />
    
  3. Add softkeyboard.js to /assets/www/js

  4. Add to the head in index.html a reference to softkeyboard.js:

    <script type="text/javascript"
         charset="utf-8"
             src="js/softkeyboard.js"></script>
    
  5. Finally call the following on the device:

    window.cordova.plugins.SoftKeyBoard.hide(function () {
      // WooHoo!
    },function () {
      // BooHoo!
    });
    

So far I can only see that you've done step 2 & 5.

Updated it was a namespace issue it seems, and I've also updated to reflect that. Glad it worked.

Upvotes: 1

Related Questions