How to force keyboard to show/hide?
This question already has an answer here:
这应该工作
public class KeyBoard {
public static void toggle(Activity activity){
InputMethodManager imm = (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE);
if (imm.isActive()){
imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0); // hide
} else {
imm.toggleSoftInput(0, InputMethodManager.HIDE_IMPLICIT_ONLY); // show
}
}//end method
}//end class
this link is clear about hiding the soft keyboard. to show it you can use a hack - create an EditText anywhere in your layout, layout_width and layout_height=0dip, and in onCreate do
yourEditText.requestFocus();
链接地址: http://www.djcxy.com/p/16598.html
上一篇: 防止软键盘在Android后退按钮上关闭
下一篇: 如何强制键盘显示/隐藏?