Android软键盘永远不会出现在模拟器中

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

上一篇:iOS 8 自定义键盘 下一篇:OnScreen 键盘在 Activity 启动时自动打开

相关文章

最新文章