閱讀588 返回首頁    go 微軟 go Office


android如何調用顯示和隱藏係統默認的輸入法

原文:https://soft-dev.iteye.com/blog/1073676


1.調用顯示係統默認的輸入法 

方法一、 

InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); 
imm.showSoftInput(m_receiverView(接受軟鍵盤輸入的視圖(View)),InputMethodManager.SHOW_FORCED(提供當前操作的標記,SHOW_FORCED表示強製顯示)); 

方法二、 
InputMethodManager m=(InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); 
m.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS); (這個方法可以實現輸入法在窗口上切換顯示,如果輸入法在窗口上已經顯示,則隱藏,如果隱藏,則顯示輸入法到窗口上) 


2.調用隱藏係統默認的輸入法 
((InputMethodManager)getSystemService(INPUT_METHOD_SERVICE)).hideSoftInputFromWindow(WidgetSearchActivity.this.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); (WidgetSearchActivity是當前的Activity)


3.獲取輸入法打開的狀態 
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE); 
boolean isOpen=imm.isActive(); 
isOpen若返回true,則表示輸入法打開

最後更新:2017-04-02 06:52:05

  上一篇:go 理解Android的手勢識別
  下一篇:go SQL GETDATE()日期格式化函數