Android softkeyboard never shows up in emulator(Android软键盘永远不会出现在模拟器中)
问题描述
我是 Android 新手.我已经花了两个小时搜索.无论我尝试什么软键盘,都不会为我的 EditText
显示.我简单地创建它:
I'm new to Android. I've spent two hours already for searching. Whatever i try softkeyboard is never shown for my EditText
. I create it simply:
EditText editText = (EditText)findViewById(R.id.editText);
我试过了:
editText.requestFocus();//i tried without this line too
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT);
和:
editText.setOnFocusChangeListener(new OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus)
{
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT);
}
});
我也试过了:
getWindow().setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_VISIBLE);
我尝试将此行放入 AndroidManifest.xml
文件:
i tried putting this line into AndroidManifest.xml
file:
android:windowSoftInputMode="stateVisible|adjustResize"
但一切都是徒劳的.它只是从不显示.我错过了什么?
but all in vain. It just never shows. What am i missing?
推荐答案
您需要确保您的模拟器未设置为使用硬件键盘.这可以通过在 AVD 中选择的模拟器上选择 Edit
来完成.然后取消选中Hardware keyboard present
设置.
You need to make sure that your emulator is not set to use a hardware keyboard. This can be done by choosing Edit
on a selected emulator in the AVD. Then uncheck the Hardware keyboard present
setting.
您也可以尝试使用其他模拟器,例如 Genymotion.它支持完整的硬件加速(多核 CPU 和 GPU)并且运行速度比任何 android 模拟器图像都要快.如果您使用 Genymotion,您需要在 Android 中禁用硬件键盘(详见下文).
You could also try using a different emulator, such as Genymotion. It supports full hardware acceleration (multi-core CPU as well as GPU) and runs much faster than any of the android emulator images. If you use Genymotion you will need to disable the hardware keyboard within Android (see below for details).
在 Genymotion 中禁用硬件键盘:
转到 设置
-> 语言 &输入
并打开Keyboard & 下的
.您可以打开/关闭一个 Default
项输入法Hardware
设置.当它开启时,您使用物理键盘;当它关闭时,只要文本字段获得焦点,就会弹出标准软键盘.
To disable hardware keyboard in Genymotion:
Go to Settings
-> Language & input
and open the Default
item under Keyboard & Input Methods
. There is a Hardware
setting that you can toggle on/off. When it is on you use your physical keyboard and when it is off the standard soft keyboard should pop-up whenever a text field gets focus.
Genymotion 设置的屏幕截图:
Screenshots for Genymotion settings:
这篇关于Android软键盘永远不会出现在模拟器中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Android软键盘永远不会出现在模拟器中
基础教程推荐
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01