2012-08-24 56 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; 
}