Enable or disable a keypad.
Enable and disable a keypad
Public classSoftKeyboardUtils {/***Hide a keyboard *@ ParamAcitivity */ Public static voidCloseSoftKeyboard (Activity acitivity ){If(Null! = Acitivity & acitivity. getCurrentFocus ()! =Null){If(Null! = Acitification. getWindow () {acitification. getWindow (). getDecorView (). clearFocus (); InputMethodManager im = (InputMethodManager) acitificationcontext (). getSystemService (Context. getApplicationContext.INPUT_METHOD_SERVICE));If(Null! = Im) {im. hideSoftInputFromWindow (acitivity. getWindow (). getDecorView (). getWindowToken (), InputMethodManager.HIDE_NOT_ALWAYS);}}}}/***Enable the keyboard *@ ParamAcitivity */ Public static voidOpenSoftKeyboard (FinalActivity acitivity) {Timer timer =NewTimer ();
Timer. schedule (NewTimerTask (){
@ Override
Public voidRun (){
InputMethodManager imm = (InputMethodManager) acitivity. getSystemService (Context.INPUT_METHOD_SERVICE);
Imm. toggleSoftInput (0, InputMethodManager.HIDE_NOT_ALWAYS);
}
},200 );
}
}