/** * 显示输入软件盘,焦点在传进去的view上 * * @param view */ public static void showSoftInput(Context context, View view) { if (view == null) { return; } view.requestFocus(); InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE); if (imm != null) { imm.showSoftInput(view, 0); } } /** * 隐藏输入软键盘 * * @param view */ public static void hideSoftInput(Context context, View view) { if (view == null) { return; } InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE); if (imm != null) { imm.hideSoftInputFromWindow(view.getWindowToken(), 0); } }
android调用输入法
最新推荐文章于 2022-07-15 08:44:58 发布