/** * 隐藏软键盘,显示软键盘 * Created by g on 2018/1/22. */ public class KeyboardUtils { /** * 隐藏软键盘 */ public static void hinKeyboard(Context context, View view) { InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE); if (imm != null) { imm.hideSoftInputFromWindow(view.getWindowToken(), 0); } } /** * 显示软键盘 */ public static void showKeyboard(Context context, View view) { InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE); if (imm != null) { view.requestFocus(); imm.showSoftInput(view, 0); } } }