android输入法–InputMethodManager

1.调用显示系统默认的输入法
方法一、

InputMethodManager imm = (InputMethodManager) 
getSystemService(Context.INPUT_METHOD_SERVICE);

imm.showSoftInput(m_receiverView)
,InputMethodManager.SHOW_FORCED);

方法二、

InputMethodManager m=(InputMethodManager) 
getSystemService(Context.INPUT_METHOD_SERVICE);
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.调用隐藏系统默认的输入法

((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,则表示输入法打开



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值