dialog.setOnShowListener(
new OnShowListener() {
@Override
public void onShow(DialogInterface dialog) {
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(textEdit, InputMethodManager.SHOW_IMPLICIT);
}
}
);
InputMethodManager inputMethodManager = (InputMethodManager) this
.getApplicationContext().getSystemService(
Context.INPUT_METHOD_SERVICE);
inputMethodManager
.hideSoftInputFromWindow(editText.getWindowToken(), 0); // 隐藏