Skip to content

Instantly share code, notes, and snippets.

@dohaivu
Created June 23, 2017 08:44
Show Gist options
  • Save dohaivu/f093a5a7ec175e076dada67cc41d3218 to your computer and use it in GitHub Desktop.
Save dohaivu/f093a5a7ec175e076dada67cc41d3218 to your computer and use it in GitHub Desktop.
#android keyboard
// hide keyboard
View view = this.getCurrentFocus();
if (view != null) {
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}
// show keyboard
if (view.requestFocus()) {
InputMethodManager imm = (InputMethodManager)
mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT);
}
/*
Add this to activity to resize it when show soft keyboard
android:windowSoftInputMode="adjustResize"
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment