Detect if phone's keyboard is slid out

只愿长相守 提交于 2020-01-01 19:23:07

问题


I'd like to set focus to an EditText and automatically bring up the virtual keyboard in certain situations. However, if a phone's hardware keyboard is slid out, I wouldn't want to. Is there any way to detect whether or not a phone's hardware keyboard (if one exists) is slid out? Or is there some functionality of the EditText that will handle all this for me?


回答1:


if (getResources().getConfiguration().hardKeyboardHidden==Configuration.HARDKEYBOARDHIDDEN_NO)
    {
    //do stuff
    }

To dive deeper, triggering OnConfigurationChanged on keyboard slide is explained in Activity restart on rotation Android



来源:https://stackoverflow.com/questions/4072882/detect-if-phones-keyboard-is-slid-out

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!