【问题标题】:disable softkeypad is popping up automatically禁用软键盘自动弹出
【发布时间】:2014-07-03 04:20:48
【问题描述】:

当我按下按钮时,软键盘会自动弹出...我尝试了以下代码来停止弹出软键盘但徒劳无功...以下是我尝试过的代码:

public void hideKeyboard(View view) {
        InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Airport.INPUT_METHOD_SERVICE);
        inputMethodManager.hideSoftInputFromWindow(view.getWindowToken(), 0);
    }

即使在 ma​​nifest 文件中,我也做了以下操作:

android:windowSoftInputMode="stateHidden"

但令人惊讶的是我没有使用任何编辑文本...而且这个软键盘正在弹出....任何人都可以回答这个....这是紧急情况...谢谢你提前

【问题讨论】:

  • 有没有什么可以控制你把注意力放在哪里?
  • 请您发布您的按钮点击方法..
  • 只需从清单中删除 android:windowSoftInputMode="stateHidden" 这一行。
  • public void onClick(View v) { if (v.getId() == R.id.air_pick) { Intent intent = new Intent(v.getContext(), Airport.class); startActivityForResult(intent, 0); ....air_pick 是按钮....而 Airport 是另一个我想从 Main 类调用的类...这个 Airport 类只包含按钮,什么都没有....这段代码来自 Main.java 类....请任何人都可以解决这个...??感谢所有试图帮助我的人..
  • 在你的清单中试试这个 android:windowSoftInputMode="stateAlwaysHidden"

标签: java android eclipse android-activity


【解决方案1】:

试试这个有趣的隐藏软键盘

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);

【讨论】:

  • 你达到目标了吗
  • 这也不起作用...这是一个真正的问题...还有其他方法吗...??
  • 发布你的点击方法,我来帮忙
  • public void onClick(View v) { if (v.getId() == R.id.air_pick) { Intent i = new Intent(Main.this, Airport.class); startActivity(i);........在这段代码中 air_pick 是要被点击的按钮,它在 Main.java 类中......点击它之后焦点应该转移到 Airport.class....这个机场.java 只包含 4 个按钮,没有其他任何东西......当按下 air_pick 按钮时,Airport.java 被调用,同时软键盘弹出......
  • InputMethodManager imm = (InputMethodManager) getSystemService(Activity.INPUT_METHOD_SERVICE); imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);试试这个,让我通知
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-04-16
  • 2017-01-05
  • 1970-01-01
  • 2015-08-25
  • 2011-06-15
  • 1970-01-01
相关资源
最近更新 更多