本文介绍了如果检测手机的键盘滑出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将焦点设置到一个EditText,并自动在某些情况下,调出虚拟键盘。但是,如果一个手机的硬件键盘滑出,我不想。有什么方法来检测是否有手机的硬件键盘(如果存在的话)滑出?或者是那里的EditText的一些功能将处理这一切对我?

解决方案

 如果(getResources()。getConfiguration()。hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_NO)
    {
    //做的东西
    }
 

要潜得更深,从而引发OnConfigurationChanged在键盘上滑动的http://stackoverflow.com/questions/456211/activity-restart-on-rotation-android

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?

解决方案
if (getResources().getConfiguration().hardKeyboardHidden==Configuration.HARDKEYBOARDHIDDEN_NO)
    {
    //do stuff
    }

To dive deeper, triggering OnConfigurationChanged on keyboard slide is explained in http://stackoverflow.com/questions/456211/activity-restart-on-rotation-android

这篇关于如果检测手机的键盘滑出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-29 21:42