gpt4 book ai didi

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

转载 作者:IT老高 更新时间:2023-10-28 13:09:20 25 4
gpt4 key购买 nike

我是 Android 新手。我已经花了两个小时搜索。无论我尝试什么软键盘,都不会为我的 EditText 显示。我简单地创建它:

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 文件:

 android:windowSoftInputMode="stateVisible|adjustResize"

但一切都是徒劳的。它只是从不显示。我错过了什么?

最佳答案

您需要确保您的模拟器未设置为使用硬件键盘。这可以通过在 AVD 中选择的模拟器上选择 Edit 来完成。然后取消选中Hardware keyboard present设置。

您也可以尝试使用不同的模拟器,例如 Genymotion .它支持完整的硬件加速(多核 CPU 和 GPU)并且运行速度比任何 android 模拟器图像都要快。如果您使用 Genymotion,您需要在 Android 中禁用硬件键盘(详见下文)。

在 Genymotion 中禁用硬件键盘:
转到Settings -> Language & input 并打开Keyboard & Input Methods 下的Default 项。您可以打开/关闭一个 Hardware 设置。当它开启时,您使用物理键盘;当它关闭时,只要文本字段获得焦点,就会弹出标准软键盘。

Genymotion 设置的屏幕截图: Default Item

enter image description here

关于Android软键盘永远不会出现在模拟器中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18288228/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com