打开Activity时,不自动显示(弹出)虚拟键盘
在AndroidManifest.xml文件中<activity>标签中添加属性
android:windowSoftInputMode="stateHidden|adjustResize"
如果要显示就更改属性
android:windowSoftInputMode="stateVisible|adjustResize"
隐藏输入法
InputMethodManager im=(InputMethodManager)getSystemService
(Context.INPUT_METHOD_SERVICE);
im.hideSoftInputFromWindow(edittext.getWindowToken(),0);
显示输入法
editText.setFocusable(true);
editText.setFocusableInTouchMode(true);
editText.requestFocus();
activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);