package com.quark.utils;
import android.content.Context;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
/**
* 软键盘辅助类
* Created by wyw on 2015/8/15.
*/
public class SoftKeyboardUtils {
public static void closeBoard(Context mcontext) {
InputMethodManager imm = (InputMethodManager) mcontext
.getSystemService(Context.INPUT_METHOD_SERVICE);
// imm.hideSoftInputFromWindow(myEditText.getWindowToken(), 0);
if (imm.isActive()) //一直是true
imm.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT,
InputMethodManager.HIDE_NOT_ALWAYS);
}
public static void hideSystemKeyBoard(Context mcontext, View v) {
InputMethodManager imm = (InputMethodManager) mcontext
.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
}
public static void openSystemKeyBoard(Context mcontext, View v) {
InputMethodManager imm = (InputMethodManager) mcontext.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(v,InputMethodManager.SHOW_FORCED);
}
}