Android studio version :2.3.3 The code below is not working and it should hide the keyboard but its not.Please help.
InputMethodManager imm = (InputMethodManager)
getSystemService(Context.INPUT_METHOD_SERVICE);
public void setImm(InputMethodManager imm) {
this.imm = imm;
}
public InputMethodManager getImm() {
imm.hideSoftInputFromWindow(urledit.getWindowToken(),0);
return imm;
}
/**
* Hides the soft keyboard
*/
public void hideSoftKeyboard() {
if(getCurrentFocus()!=null) {
InputMethodManager inputMethodManager = (InputMethodManager)
getSystemService(INPUT_METHOD_SERVICE);
inputMethodManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
}
}
/**
* Shows the soft keyboard
*/
public void showSoftKeyboard(View view) {
InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
view.requestFocus();
inputMethodManager.showSoftInput(view, 0);
}
Try this to hide and show keyboard