我需要根據語言的變化改變鍵盤。如何以編程方式更改輸入法?
我已經做了一些研究,發現它可以使用這些API
- InputMethodManager setInputMethod(android.os.IBinder,java.lang.String中)
- InputMethodService switchInputMethod(完成java.lang.String中)
對於第一API,我需要一個的IBinder令牌其可以是通過調用
mInputMethodService.getWindow()從InputMethodService實例作出。getWindow()。的getAttributes()。令牌
,或者如果我有參考InputMethodService對象我可以簡單地調用
mInputMethodService.switchInputMethod(ID)
改變輸入法。
真正的問題是如何獲得對InputMethodService對象的引用。
PS: 我不想使用InputMethodManager的showInputMethodPicker()因爲我的要求我想從具有語言列表我現有的對話框更改 它。
我知道這對用戶應用程序來說是不可能的,但不知道系統應用程序是否也不可能。
謝謝你,這真棒。 –