隱藏輸入法並退出當前的Activity

2021-08-26 04:56:34 字數 423 閱讀 4496

在當前的activity彈出輸入法框的時候,按下返回鍵,輸入框消失,而不會退出當前的activity,在有些時候,我們可能需要退出當前的activity,可以重寫dispatchkeyeventpreime()方法來做到這一點:

@override public boolean dispatchkeyeventpreime(keyevent event) else if (event.getaction() == keyevent.action_up) } return super.dispatchkeyeventpreime(event); }

隱藏輸入法:

protected void hideinputmethod() }

獲取到activity"

private activity getactivity() return null; }

Android 隱藏輸入法

對於edittext 可以設定setinputtype inputtype.type null 輸入法就不會彈出。需要的時候在動態設定inputtyep.如果一載入activity 可以用getwindow setsoftinputmode windowmanager.layoutparams.so...

獲取當前的輸入法狀態

1.hwnd wingethandle classname notepad keystr getkeyboardlayout hwnd keyname regread hkey local machine system currentcontrolset control keyboard layou...

得到並設定輸入法

private sub form1 load byval sender as system.object,byval e as system.eventargs handles mybase.load dim objlang as inputlanguage for each objlang in ...