【问题标题】:Android hide keyboard on btn click [duplicate]Android在btn上隐藏键盘单击[重复]
【发布时间】:2013-03-03 21:33:48
【问题描述】:

我想在按钮的点击事件中隐藏键盘。任何帮助将不胜感激

【问题讨论】:

    标签: android android-keypad


    【解决方案1】:
    InputMethodManager inputManager = (InputMethodManager)
                                      getSystemService(Context.INPUT_METHOD_SERVICE); 
    
    inputManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(),
                                         InputMethodManager.HIDE_NOT_ALWAYS);
    

    我把它放在 onClick(View v) 事件之后。 你需要import android.view.inputmethod.InputMethodManager;

    点击按钮时键盘隐藏。

    【讨论】:

      【解决方案2】:

      隐藏虚拟键盘:

      InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
      imm.hideSoftInputFromWindow(editView.getWindowToken(), 0);
      

      【讨论】:

        猜你喜欢
        • 2012-11-15
        • 1970-01-01
        • 2022-01-18
        • 1970-01-01
        • 2012-05-10
        • 2017-02-16
        • 1970-01-01
        • 2020-10-15
        • 1970-01-01
        相关资源
        最近更新 更多