Java 禁用软键盘将自动弹出

Java 禁用软键盘将自动弹出,java,android,eclipse,android-activity,Java,Android,Eclipse,Android Activity,当我按下按钮时,软键盘会自动弹出…我尝试了以下代码来停止弹出软键盘,但没有成功…以下是我尝试的代码: public void hideKeyboard(View view) { InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Airport.INPUT_METHOD_SERVICE); inputMethodManager.hideSoftInputFrom

当我按下按钮时,软键盘会自动弹出…我尝试了以下代码来停止弹出软键盘,但没有成功…以下是我尝试的代码:

public void hideKeyboard(View view) {
        InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Airport.INPUT_METHOD_SERVICE);
        inputMethodManager.hideSoftInputFromWindow(view.getWindowToken(), 0);
    }
即使在清单文件中,我也做了以下工作:

android:windowSoftInputMode="stateHidden"

但令人惊讶的是,我没有使用任何编辑文本…而且这个软键盘正在弹出…有人能回答这个问题吗…这是紧急情况…在高级中谢谢你尝试这个隐藏软键盘很有趣

InputMethodManager inputManager = (InputMethodManager) this
            .getSystemService(Context.INPUT_METHOD_SERVICE);

    //check if no view has focus:
    View v=this.getCurrentFocus();
    if(v==null)
        return;

    inputManager.hideSoftInputFromWindow(v.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);

你的焦点在哪里?请你发布你的按钮点击方法。只需从manifest.public void onClick(View v)中删除android:WindowsOfInputMode=“stateHidden”这一行{if(v.getId()==R.id.air_pick){Intent Intent Intent=new Intent(v.getContext(),Airport.class);startActivityForResult(Intent,0)…air_pick是按钮…Airport是我想从Main类调用的另一个类…这个Airport类只包含按钮,什么都不包含…这个代码来自Main.java类…请任何人都能解决这个问题…?感谢所有试图帮助我的人…在你的清单android:WindowsofInputMode中尝试这个=“stateAllwayshidden”你达到目标了吗这也没用…这是一个真正的问题…还有其他方法吗…?发布你的onclick方法,我将帮助public void onclick(视图v){if(v.getId()==R.id.air_pick){Intent i=new Intent(Main.this,Airport.class);startActivity(i)..在这段代码中,air_pick是要单击的按钮,它位于Main.java类中…单击后,焦点应转移到Airport.class….此Airport.java仅包含4个按钮,其他什么都没有….当按下air_pick按钮时,将调用Airport.java,同时弹出软键盘…InputMethodManager imm=(InputMethodManager)getSystemService(Activity.INPUT\u METHOD\u SERVICE);imm.toggleSoftInput(InputMethodManager.HIDE\u IMPLICIT\u ONLY,0);尝试此操作并通知我