Friday, 2 January 2015

Show or Hide soft keyboard in Android

Show or Hide soft keyboard on opening a dialog or activity in android

For showing the soft keyboard on entering into the activity or to the dialog we can use this coding
Code Snippet:
1
2
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED,0);

and for hiding the keyboard
Code Snippet:
1
2
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(singleedittext.getWindowToken(),0);

Enjoy!!!!!!!!!!!

No comments: