後,我調用的方法是這樣的:鍵盤將不顯示主叫InputMethodManager.showSoftInput
getInputMethodManager().showSoftInput(view, 0, resultReceiver);
但是,鍵盤不顯示我的屏幕上,並resultReceiver不onReceiveResult(int resultCode, Bundle resultData)
收到一條消息。該視圖不爲空,並且hasFocus() == true
。
有沒有人知道這個問題?非常感謝。
謝謝Karthik和Imen。我需要知道爲什麼這種方法不起作用的根本原因,但不是一些解決方法。
更新於2017年10月23日:
我debuged到Android SDK中的源代碼,並發現:一個名爲mServedView
變量爲空並且該方法將返回一個false
。然而,[官方文檔](https://developer.android.com/reference/android/view/inputmethod/InputMethodManager.html#showSoftInput(android.view.View,int,android.os.ResultReceiver)不會告訴爲什麼或何時此方法將返回false
。
KARTHIK,謝謝您的回答但它不能解決我的問題。在我的情況下,我不想使用'toggleSoftInput'而不是'showSoftInput',並且我不能使用'InputMethodManager.SHOW_FORCED',因爲它是一種util方法。標誌需要傳入此方法。 – freshomer