我需要在按下隐藏键盘时检测隐藏的键盘 我的源代码
<activity
android:name="com.teamios.info.activity.MainScreenActivity"
android:screenOrientation="landscape"
android:theme="@style/Theme.MyScreenTranNorman"
android:configChanges="orientation|keyboardHidden"
android:windowSoftInputMode="stateUnchanged|adjustPan" />
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
Toast.makeText(this, "keyboard visible", Toast.LENGTH_SHORT).show();
}
我测试了三星Galaxy nexus手机android os 4.2.1,但Toast没有显示键盘隐藏的时候
请帮帮我。
答案 0 :(得分:1)
<activity
android:name="com.teamios.info.activity.MainScreenActivity"
android:theme="@style/Theme.MyScreenTranNorman"
android:configChanges="orientation|keyboardHidden"
android:windowSoftInputMode="stateUnchanged|adjustPan" />
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
if (newConfig.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_NO) {
Toast.makeText(this, "keyboard visible", Toast.LENGTH_SHORT).show();
} else if (newConfig.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_YES) {
Toast.makeText(this, "keyboard hidden", Toast.LENGTH_SHORT).show();
}
}
并添加
<activity android:name=".MyActivity" android:screenOrientation="landscape " > </activity>
。
答案 1 :(得分:0)
您是否在清单文件中添加了 android:configChanges =“keyboardHidden”?