【问题标题】:How to show the soft keyboard on device with hard keyboard when hkbd is closed?hkbd关闭时如何在带有硬键盘的设备上显示软键盘?
【发布时间】:2011-07-29 12:52:49
【问题描述】:

我有第一个(已解决的)问题SO Android show softkeybard ...的推论问题

关闭滑动键盘后,我希望我的活动在启动时显示键盘。

在我的活动清单中设置的“stateVisible”应适用相同的清单。我需要任何带有InputMethodManger 的显式代码吗?再次,我尝试了明显的方法和标志,但它不会在带有滑动键盘的手机上打开键盘。

为方便起见,将清单复制到此处:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.mycompany.android.studyIme"
      android:versionCode="1"
      android:versionName="1.0">
    <uses-sdk android:minSdkVersion="7" />

    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".StudyImeActivity"
                  android:label="@string/app_name" 
                  android:windowSoftInputMode="stateAlwaysVisible|stateVisible">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

    </application>
</manifest>

【问题讨论】:

    标签: android keyboard android-input-method


    【解决方案1】:

    我的同事解决了这个问题。她没有尝试强制展示,而是使用“切换”方法演示了解决方案。

     InputMethodManager imm = (InputMethodManager) getApplicationContext().getSystemService(Context.INPUT_METHOD_SERVICE); 
     imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0); 
    

    当然,您可能希望将其包含在键盘状态的配置检查中。

    【讨论】:

    • 但是如何查看键盘的状态呢?我认为这是一个很好的问题。
    猜你喜欢
    • 2014-06-27
    • 2011-03-20
    • 1970-01-01
    • 2022-11-18
    • 2018-02-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多