package com.xinke.Poseidon.fragment.information.luntan.utils;
import android.content.Context;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
/**
* 康:键盘处理工具类
*/
public class CommonUtils {
public static void showSoftInput(Context context, View view){
InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);
//imm.showSoftInput(view, InputMethodManager.SHOW_FORCED);
}
public static void hideSoftInput(Context context, View view){
InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(view.getWindowToken(), 0); //强制隐藏键盘
}
public static boolean isShowSoftInput(Context context){
InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
//获取状态信息
return imm.isActive();//true 打开
}
}
调用:
CommonUtils.hideSoftInput(editText.getContext(), editText);