键盘工具类

public class KeyboardUtils {

    /**

    * 显示键盘

    * @param view

    */

    public static voiddisplaySoft(View view) {

        InputMethodManager imm = (InputMethodManager)view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);

imm.showSoftInput(view, InputMethodManager.SHOW_FORCED);

    }

    /**

    * 隐藏键盘

    */

    public static voidhideSoft(View view) {

        InputMethodManager imm = (InputMethodManager)view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);

imm.hideSoftInputFromWindow(view.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);

    }

}

你可能感兴趣的:(键盘工具类)