android调用输入法

来源:互联网 发布:中国依赖进口数据 编辑:程序博客网 时间:2024/06/05 20:06
/** * 显示输入软件盘,焦点在传进去的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);   }}
0 0