2

My question is very simple. I just need to know what event this close keyboard button produces. I want to listen for the event and execute a simple method when the event is captured... I have searched many questions but all the solutions I tried was directed at other key events.

KEYBOARD CLOSE BUTTON

Goo
  • 1,308
  • 1
  • 13
  • 29
the-ginger-geek
  • 6,745
  • 4
  • 25
  • 42
  • chek out this link, you will get your answer .... [http://stackoverflow.com/questions/4312319/howto-capture-the-virtual-keyboard-show-hide-event-in-android][1] [1]: http://stackoverflow.com/questions/4312319/howto-capture-the-virtual-keyboard-show-hide-event-in-android – Daud Arfin Jul 06 '12 at 11:05
  • That only works for hard keyboards. I tried the method in the answer but the event is not captured. – the-ginger-geek Jul 06 '12 at 11:20
  • This can help you ... http://stackoverflow.com/questions/3940127/intercept-back-button-from-soft-keyboard – user1862721 Nov 29 '12 at 09:44

1 Answers1

0

I have researched this a little before and kept crossing conversations where people were saying that there isn't such an event to capture.

Not sure what you are wanting to capture this event for but, here is a little work around that helped me:

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

Source. Let me know if that helps

Community
  • 1
  • 1
jnthnjns
  • 8,894
  • 4
  • 39
  • 65
  • Wont this only work if you use adjustResize in your manifest? I am using adjustPan which does not remeasure the layout when the keyboard opens. – the-ginger-geek Jul 07 '12 at 09:16