0

Which event triggers when we hide / show the keyboard at the android in Javascript? How can I subscribe? I need to show my block after the keyboard completely hides.

Brian Tompsett - 汤莱恩
  • 5,195
  • 62
  • 50
  • 120
Lavr1k
  • 3
  • 2

1 Answers1

-1

It's this thing I found here:

@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    final int proposedheight = MeasureSpec.getSize(heightMeasureSpec);
    final int actualHeight = getHeight();

    if (actualHeight > proposedheight){
        // Keyboard is shown
    } else {
        // Keyboard is hidden
    }

    super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}

Or you can use the method from here:

@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);


    // Checks whether a hardware keyboard is available
    if (newConfig.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_NO) {
        Toast.makeText(this, "keyboard visible", Toast.LENGTH_SHORT).show();
    } else if (newConfig.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_YES) {
        Toast.makeText(this, "keyboard hidden", Toast.LENGTH_SHORT).show();
    }
}
Community
  • 1
  • 1
g00dy
  • 6,652
  • 2
  • 28
  • 42
  • It's java, when the event is caught there, then the javascript block could be executed. – g00dy Sep 11 '13 at 12:34