1.開啟輸入法視窗
inputmethodmanager imm = (inputmethodmanager)getsystemservice(context.input_method_service);
// 接受軟鍵盤輸入的編輯文字或其它檢視
imm.showsoftinput(edittext,inputmethodmanager.show_forced);
2.關閉輸入法視窗
inputmethodmanager imm = (inputmethodmanager)getsystemservice(context.input_method_service);
imm.hidesoftinputfromwindow(mainactivity.this.getcurrentfocus().getwindowtoken(),
inputmethodmanager.hide_not_always);
3.如果輸入法開啟則關閉,如果沒開啟則開啟
inputmethodmanager imm = (inputmethodmanager)getsystemservice(context.input_method_service);
imm.togglesoftinput(0, inputmethodmanager.hide_not_always);
4.獲取輸入法開啟的狀態
inputmethodmanager imm = (inputmethodmanager)getsystemservice(context.input_method_service);
boolean isopen=imm.isactive();
isopen若返回true,則表示輸入法開啟,否則為關閉
Android程式開啟和關閉輸入法
一 開啟輸入法視窗 inputmethodmanager inputmethodmanager inputmethodmanager getsystemservice context.input method service 接受軟鍵盤輸入的編輯文字或其它檢視 imm.showsoftinput s...
Android程式開啟和關閉輸入法
一 開啟輸入法視窗 inputmethodmanager inputmethodmanager inputmethodmanager getsystemservice context.input method service 接受軟鍵盤輸入的編輯文字或其它檢視 imm.showsoftinput s...
開啟和關閉輸入法
procedure closeedtime edt tedit varkeystates tkeyboardstate begin getkeyboardstate keystates if keystates vk capital 1 then begin setcapslockkey vk ca...