/**
* 控制手机虚拟键盘的显示和隐藏
*/
public class InputMethodUtil {

/**
* 隐藏虚拟键盘
* @param v  参数v为获取焦点对象view
*/
public static void hideKeyboard(View v) {
InputMethodManager imm = (InputMethodManager) v.getContext()
.getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm.isActive()) {
imm.hideSoftInputFromWindow(v.getApplicationWindowToken(), 0);

}
}
/**
* 显示虚拟键盘
* @param v 参数v为获取焦点对象view
*/
public static void showKeyboard(View v){
InputMethodManager imm = (InputMethodManager) v.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(v, InputMethodManager.SHOW_FORCED);
}
}