我有一个activity打开一个包含dialog点击的内容。节目一开场。我想防止这种情况。只有当我点击 时才会出现。我使用的是安卓 4。edittextsbuttondialogsoftkeyboardedittextdialogsoftkeyboard
提前致谢
我有一个activity打开一个包含dialog点击的内容。节目一开场。我想防止这种情况。只有当我点击 时才会出现。我使用的是安卓 4。edittextsbuttondialogsoftkeyboardedittextdialogsoftkeyboard
提前致谢
为此,请在调用 dialog.Show() 之前设置软输入模式:
// Build and create your dialog.
AlertDialog dialog = new AlertDialogBuilder(...).create();
// Hide soft keypad by default (will be displayed when user touches any edit field).
dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
// Show the dialog.
dialog.show();
    这应该在任何情况下都有效:
public void hideKeyboard() {
            mActivity.runOnUiThread(new Runnable() {
                public void run() {
                    InputMethodManager inputManager = (InputMethodManager) mActivity
                            .getSystemService(Context.INPUT_METHOD_SERVICE);
                    inputManager.hideSoftInputFromWindow(mActivity
                            .getCurrentFocus().getWindowToken(),
                            InputMethodManager.HIDE_NOT_ALWAYS);
                }
            });
        }
    将此添加到您的清单中就是您所要做的:
安卓:windowSoftInputMode="stateHidden"
很简单,但万一有人在看这里
:)