I have an EditText and want to give it more lines when the keyboard appears. So i am looking for something like a "OnKeyboardAppearsListener" but can't find it. I think it must exist, but perhaps in a different way...
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
You have to @Override onConfigurationChanged
to be able to handle runtime changes:
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
// Checks whether a hardware or on-screen keyboard is available
if (newConfig.keyboardHidden == Configuration.KEYBOARDHIDDEN_NO) {
Toast.makeText(this, "Keyboard visible", Toast.LENGTH_SHORT).show();
} else if (newConfig.keyboardHidden == Configuration.KEYBOARDHIDDEN_YES) {
Toast.makeText(this, "Keyboard hidden", Toast.LENGTH_SHORT).show();
}
}
Example taken from here. Take a look here for keyboard related (among others) fields you might want to use.
Edit (RivieraKid): Changed to take account of hard or on-screen keyboard.