鍵盤控制

這個判斷每次都是true
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
// 獲得InputMethodManager的實例
if (imm.isActive()) {
	imm.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT, InputMethodManager.HIDE_NOT_ALWAYS);
	// 關閉軟鍵盤,開啓方法相同,這個方法是切換開啓與關閉狀態的
}
強制關閉鍵盤
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(EvaluateActiivty.this.getCurrentFocus().getWindowToken(), 0);
 
View view = getWindow().peekDecorView();
if (view != null) {
	InputMethodManager inputmanger = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
	inputmanger.hideSoftInputFromWindow(view.getWindowToken(), 0);
}


版權聲明:本文爲博主原創文章,未經博主容許不得轉載。java

相關文章
相關標籤/搜索