隐藏输入法软件盘及键盘响应

//此方法,如果显示则隐藏,如果隐藏则显示
private void hintKbOne() {
InputMethodManager imm = (InputMethodManager)getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);	  
// 得到InputMethodManager的实例
if (imm.isActive()) {
 // 如果开启
imm.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT,
InputMethodManager.HIDE_NOT_ALWAYS);
	    
	}

}

//此方法只是关闭软键盘
private void hintKbTwo() {
 InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);			 
 if(imm.isActive()&&getCurrentFocus()!=null){
	if (getCurrentFocus().getWindowToken()!=null) {
	imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
	}			  
 }
}
软件盘响应请参开博客:

http://blog.csdn.net/wang_shaner/article/details/8467688


猜你喜欢

转载自blog.csdn.net/purple7826/article/details/45848211