2012-08-24 55 views
0

可能重复:
Is there a way to tell if the soft-keyboard is shown?如何勾选SoftKeyboard显示在活动屏幕上?

在一种应用我想要查询Softkeyboard显示在活动屏幕上。

plz帮助

+0

我想我们可以显示和隐藏软键盘,但是我们无法获得软键盘的可见性状态。 – sankar

+2

走[这个问题](http://stackoverflow.com/questions/3568919/android-how-can-i-tell-if-the-soft-keyboard-is-showing-or-not),它显示为尽管无法检查。 – Closeratio

回答

1

有一个解决办法,如果你有兴趣,你可以使用getCurrentFocus()返回其处于焦点的观点,并检查它的EditText的实例,如果是,那么你知道softkeyboard可见,提供了软键盘中的主要输入,而不是物理键盘。

protected boolean IsSoftKeyboardVisible(){ 
if(getCurrentFocus()!=null && getCurrentFocus() instanceof EditText){ 
     return true; 
    } 
return false; 
}