2012-07-06 215 views
2

我的问题很简单。我只需要知道这个关闭键盘按钮产生什么事件。我想听取事件并在事件被捕获时执行一个简单的方法......我搜索了很多问题,但是我尝试的所有解决方案都针对其他重要事件。软键盘按钮

KEYBOARD CLOSE BUTTON

+0

赤这个链接,你会得到你的答案.... [http://stackoverflow.com/questions/4312319/howto-capture-the-virtual-keyboard-显示隐藏事件功能于机器人] [1] [1]:http://stackoverflow.com/questions/4312319/howto-capture-the-virtual-keyboard-show-hide-event -in-android – 2012-07-06 11:05:23

+0

这只适用于硬键盘。我在答案中尝试了方法,但未捕获事件。 – Neil 2012-07-06 11:20:52

+0

这可以帮助你...... http://stackoverflow.com/questions/3940127/intercept-back-button-from-soft-keyboard – user1862721 2012-11-29 09:44:05

回答

0

我以前有点研究这一点,并不停地道口,人都在说,没有这样的捕获事件的对话。

不知道你想要什么捕捉到这一事件,但是,这里是一个小的工作围绕着帮助我:

@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。让我知道这是否有助于

+0

惯于如果您在使用清单此adjustResize唯一的工作?我正在使用adjustPan,它不会在键盘打开时重新排列布局。 – Neil 2012-07-07 09:16:39