1.类imeutil.java

public class ImeUtil {
    public static void hideIme(Activity context){
        if(context==null)
            return;
        final View v = context.getWindow().peekDecorView();
        if (v != null && v.getWindowToken() != null) {
            InputMethodManager imm = (InputMethodManager) context.getSystemService(context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
        }
    }
    public static boolean isImeShow(Context context){
        InputMethodManager imm = (InputMethodManager) context.getSystemService(context.INPUT_METHOD_SERVICE);
        return imm.isActive();
    }
}

 

2.调用判断方法

if(ImeUtil.isImeShow(view.getContext()))
ImeUtil.hideIme((Activity)view.getContext());
else
view.ShowInputEdit();