找了很久的东西,今天终于搞定了

     //隐藏软键盘
     ((InputMethodManager)getSystemService(INPUT_METHOD_SERVICE)).hideSoftInputFromWindow(WidgetSearchActivity.this.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);

     //显示软键盘,控件ID可以是EditText,TextView,android 1.6的SDK本身有问题,无法设置manifest文件或者直接show出软键盘,preformclick也不行,必须手动click一个控件
     ((InputMethodManager)getSystemService(INPUT_METHOD_SERVICE)).showSoftInput(控件ID, 0);
Trackback

4 comments untill now

  1. hi, 我也想直接显示键盘,可是我照着很多人说的做了,还是没有显示。请问你是在emulator上面作的么? 能不能把你的代码发给我? 我的邮箱是conica.c@gmail.com

  2. 我望写了,android本身sdk1.6有问题,通过设置manifest文件或者硬编码preformClick一个控件或者直接show是显示不出软键盘的

  3. 隐藏软键盘的语句里的WidgetSearchActivity是哪个包里的,我没找到呀!!!!!

  4. 隐藏键盘包:android.view.inputmethod.InputMethodManager.hideSoftInputFromWindow

Add your comment now

请输入正确答案: 1+7= (required)