Android 怎么实现 点击 按钮隐藏输入法键盘

2025-04-18 17:22:02
推荐回答(1个)
回答1:

点击按钮后,在你的按钮监听方法里面调用,隐藏键盘的方法即可:

InputMethodManager inputMethodManager =(InputMethodManager)activity.getApplicationContext().  
            getSystemService(Context.INPUT_METHOD_SERVICE);   
          
EditText editText = (EditText)findViewById(R.id.xxxx);   
inputMethodManager.hideSoftInputFromWindow(editText.getWindowToken(), 0); //隐藏