1. 程式人生 > >Android隱藏輸入法

Android隱藏輸入法

	/**
	 * 隱藏輸入法鍵盤
	 * 
	 * @param activity
	 */
	public static void hideKeyboard(Activity activity) {
		if (activity == null)
			return;
		View focusedView = activity.getCurrentFocus();
		if (focusedView != null) {
			InputMethodManager mm = ((InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE));
			mm.hideSoftInputFromWindow(focusedView.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
		}
	}