android 输入法如何启动流程_android输入法状态控制
在應(yīng)用程序中,我們經(jīng)常需要控制EditText的輸入法打開(kāi)與關(guān)閉,手指touch之后,自動(dòng)打開(kāi)了輸入法,可是怎么控制關(guān)閉輸入法,除了輸入法自己的關(guān)閉按鈕之外,還有以下的方法。
一、打開(kāi)輸入法窗口:
InputMethodManager inputMethodManager = (InputMethodManager) ? ? ? ? ? ? ? getSystemService(Context.INPUT_METHOD_SERVICE);
// 接受軟鍵盤(pán)輸入的編輯文本或其它視圖
imm.showSoftInput(submitBt,InputMethodManager.SHOW_FORCED);
二、關(guān)閉出入法窗口
InputMethodManager inputMethodManager = (InputMethodManager) ? ? ? ? ? ? ? getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethodManager.hideSoftInputFromWindow(OpeListActivity.this.getCurrentFocus().getWindowToken(),
InputMethodManager.HIDE_NOT_ALWAYS);
//接受軟鍵盤(pán)輸入的編輯文本或其它視圖
inputMethodManager
.showSoftInput(submitBt,InputMethodManager.SHOW_FORCED);
三、如果輸入法打開(kāi)則關(guān)閉,如果沒(méi)打開(kāi)則打開(kāi)
InputMethodManager m=(InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
m.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);
四、獲取輸入法打開(kāi)的狀態(tài)
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
boolean isOpen=imm.isActive();
isOpen若返回true,則表示輸入法打開(kāi)
轉(zhuǎn)載:
總結(jié)
以上是生活随笔為你收集整理的android 输入法如何启动流程_android输入法状态控制的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 调查显示台湾1月消费者信心指数终止“三连
- 下一篇: OpenCV4教程——3.3 绘制直线