23. Android keypad tool ImeUtil
23. Android keypad tool ImeUtil
Public class ImeUtil {/*** display soft keyboard * View: EditText, TextView * wantPop: true = show, false = hide ** @ param context * @ param view * @ param wantPop */public static void popSoftKeyboard (Context context, View view, boolean wantPop) {InputMethodManager imm = (InputMethodManager) context. getSystemService (Context. INPUT_METHOD_SERVICE); if (wantPop) {view. requestFocus (); imm. showSoftInput (view, InputMethodManager. SHOW_IMPLICIT);} else {imm. hideSoftInputFromWindow (view. getWindowToken (), 0) ;}}/*** display the keyboard ** @ param view */public static void showSoftKeyboard (View view) {Context context = view. getContext (); InputMethodManager imm = (InputMethodManager) context. getSystemService (Context. INPUT_METHOD_SERVICE); view. requestFocus (); imm. showSoftInput (view, InputMethodManager. SHOW_IMPLICIT);}/*** hide the keyboard ** @ param view */public static void hideSoftKeyboard (View view) {Context context = view. getContext (); InputMethodManager imm = (InputMethodManager) context. getSystemService (Context. INPUT_METHOD_SERVICE); imm. hideSoftInputFromWindow (view. getWindowToken (), 0 );}}