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