我知道,根据文档,该功能用于切换软输入。但是我对作为参数传递的标志如何工作感到困惑。任何示例都是可理解的(我也想要解释,以便获得确切的功能)。谢谢!

最佳答案

显示软键盘-

InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
if(imm != null){
        imm.toggleSoftInput(0, InputMethodManager.SHOW_IMPLICIT);
    }

隐藏软键盘-
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
if(imm != null){
        imm.toggleSoftInput(0, InputMethodManager.HIDE_IMPLICIT_ONLY);
    }

关于android - 对togglesoftinput函数感到困惑,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/13933183/

10-12 02:54