【Android】 手动显示和隐藏软键盘

public class InputMethodUtil {
    private static InputMethodUtil instance;

    public static InputMethodUtil getInstance() {
        if (instance == null)
            instance = new InputMethodUtil();
        return instance;
    }

    public void hideInputMethod(Context context, View view) {
        ((InputMethodManager) context.getSystemService(context.INPUT_METHOD_SERVICE)).hideSoftInputFromWindow(view.getWindowToken(), 0);
    }

    public void showInputMethod(Context context, View view) {
        ((InputMethodManager) context.getSystemService(context.INPUT_METHOD_SERVICE)).showSoftInput(view, 0);
    }
}
posted @ 2014-06-09 16:25  NúllPòinterExcêptīon  阅读(153)  评论(0)    收藏  举报