初次进入activity聚焦编辑框的软键盘隐藏方法 :
android:windowSoftInputMode="stateHidden"
进入界面后切换焦点时软键盘的隐藏方法:
EditText.setShowSoftInputOnFocus(false);
对话框中使用时则需要在dialog.show()之后延时强制隐藏
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
InputMethodManager inputMethodManager =
(InputMethodManager)etServer.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
if (inputMethodManager != null) {
inputMethodManager.hideSoftInputFromWindow(etServer.getWindowToken(),0);
}
}
},10);