1.调用显示系统默认的输入法
方法一、
1
InputMethodManager imm = (InputMethodManager)
2
getSystemService(Context.INPUT_METHOD_SERVICE);
4
imm.showSoftInput(m_receiverView)
5
,InputMethodManager.SHOW_FORCED);
m_receiverView(接受软键盘输入的视图(View)
InputMethodManager.SHOW_FORCED(提供当前操作的标记,SHOW_FORCED表示强制显示)
方法二、
1
InputMethodManager m=(InputMethodManager)
2
getSystemService(Context.INPUT_METHOD_SERVICE);
3
m.toggleSoftInput(
0
, InputMethodManager.HIDE_NOT_ALWAYS);
这个InputMethodManager类里面的toggleSoftInput方法的API中的解释是:
This method toggles the input method window display. If the input window is already displayed, it gets hidden. If not the input window will be displayed.
这个方法在界面上切换输入法的功能,如果输入法出于现实状态,就将他隐藏,如果处于隐藏状态,就显示输入法
2.调用隐藏系统默认的输入法
1
((InputMethodManager)getSystemService(INPUT_METHOD_SERVICE))
2
.hideSoftInputFromWindow(WidgetSearchActivity.
this
.getCurrentFocus()
3
.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
(WidgetSearchActivity是当前的Activity)
3.获取输入法打开的状态
1
InputMethodManager imm = (InputMethodManager)
2
getSystemService(Context.INPUT_METHOD_SERVICE);
3
boolean
isOpen=imm.isActive();
isOpen若返回true,则表示输入法打开