Created
June 23, 2017 08:44
-
-
Save dohaivu/f093a5a7ec175e076dada67cc41d3218 to your computer and use it in GitHub Desktop.
#android keyboard
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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