问题描述
我是 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软键盘永远不会出现在模拟器中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!


大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)