如何从以往任何时候都即将在我的整个应用程序停止了android软键盘在我、应用程序、以往、键盘

2023-09-06 17:45:13 作者:肆意。

我正在开发具有内置的硬件键盘不滑出这样的硬件设备上的应用程序总是可见(如黑莓)。因此,我再也不想软键盘显示我的整个应用程序。我所知道的another SO 这个问题给出了code以下行:

I'm developing an application on a hardware device that has a built-in hardware keyboard that does not slide out so is always visible (like a blackberry). Therefore, I NEVER want the soft keyboard to display for my entire application. I'm aware of another SO question that gives the following lines of code:

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

但我不知道在哪里可以把这个code隐藏软键盘在所有的地方也有可能会出现在我的活动。我曾尝试加入code到 Activity.onUserInteraction 无济于事。这似乎显示在键盘的在的 onUserInteraction 执行。

But I don't know where to put this code to hide the soft keyboard in all places where it might possibly appear in my Activity. I have tried adding the code to Activity.onUserInteraction to no avail. It seems the keyboard appears after the onUserInteraction executes.

我也尝试添加以下到我的<活动>

I also tried adding the following to my <Activity>:

<activity 
    android:windowSoftInputMode="stateAlwaysHidden"
>

软键盘仍然出现。

Soft keyboard still appears.

推荐答案

您的应用程序不应该做任何事情。该设备的固件应该包含抑制基于硬件键盘是可见的软键盘,就像有一个硬件键盘的所有其他Android设备的配置。如果这没有发生,聊到硬件制造商,看看他们打算解决这个。

Your application should not do anything. The device's firmware should contain a configuration that inhibits the soft keyboard based on the hardware keyboard being visible, just like every other Android device that has a hardware keyboard. If that is not happening, talk to the hardware maker and see if they are planning on addressing this.

 
精彩推荐
图片推荐