Show/Hide Keyboard
- 키보드 나타내기 (Show Keyboard)
1. Creating Method
public static void showKeyboard(Activity activity) {
InputMethodManager imm = (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE);
View view = activity.getCurrentFocus();
if (view != null)
{
imm.toggleSoftInput(0, InputMethodManager.HIDE_IMPLICIT_ONLY);
}
}
2. You can use this method
showKeyboard(this);
or Just use the method
((InputMethodManager) getSystemService(Activity.INPUT_METHOD_SERVICE))
.toggleSoftInput(0, InputMethodManager.HIDE_IMPLICIT_ONLY);
- 키보드 숨기기 (Hide Keyboard)
1. Creating Method
public static void hideKeyboard(Activity activity) {
InputMethodManager imm = (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE);
View view = activity.getCurrentFocus();
if (view != null)
{
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}
}
2. You can use this method
hideKeyboard(this);
or Just use the method
((InputMethodManager) getSystemService(Activity.INPUT_METHOD_SERVICE))
.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT, 0);