Android的softkeyboard从来没有出现在仿真器仿真器、出现在、从来没有、Android

2023-09-05 08:19:33 作者:期末考时唱咆哮i

我是新来的Andr​​oid。我花了两个小时就进行搜索。无论我尝试softkeyboard从未显示我的的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);

         }
     });

我也尝试过:

i also tried:

getWindow().setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_VISIBLE);

我试图把此行到的Andr​​oidManifest.xml 文件:

 android:windowSoftInputMode="stateVisible|adjustResize"

但一切都是徒劳。它只是从来没有显示。我在想什么?

but all in vain. It just never shows. What am i missing?

推荐答案

您需要确保你的模拟器没有被设置为使用的硬件键盘。这可以通过在AVD选择的仿真器选择修改来完成。然后点击取消选中的硬件键盘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,你需要禁用范围内的Andr​​oid硬件键盘(详见下文)。

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 要禁用硬件键盘: 转到设置 - > 语言和放大器;输入,并在键盘和放大器打开默认项目;输入法。有一个硬件设置,你可以打开/关闭。当它的的您使用物理键盘,当它的关闭标准的软键盘应该弹出时的文本字段获得焦点。

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: