Java 安卓键盘永远不会出现
我试图在emulator中为我的EditText显示键盘,但不管我怎么做,它都不会出现 以下是我在XML文件中声明它的方式:Java 安卓键盘永远不会出现,java,android,xml,android-edittext,android-softkeyboard,Java,Android,Xml,Android Edittext,Android Softkeyboard,我试图在emulator中为我的EditText显示键盘,但不管我怎么做,它都不会出现 以下是我在XML文件中声明它的方式: <EditText android:id="@+id/editTextSearch" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginBottom="20dp" android:layout
<EditText
android:id="@+id/editTextSearch"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="50dp"
android:layout_weight="0.05"
android:background="@color/white"
android:ems="10"
>
</EditText>
我还在清单文件中声明了以下内容:
<activity
android:name = "com.blabla.blablabla.MyActivity"
android:windowSoftInputMode="stateVisible">
</activity>
而且键盘从未显示过。我错过了什么?试试这个
<EditText
....
<requestFocus />
</EditText>
代码在设备上工作得非常好。据我所说,模拟器的硬键盘是打开的,所以它不会显示软键盘。尝试在设备上运行此代码。尝试强制软键盘打开,如下所示:
InputMethodManager imm=(InputMethodManager)getSystemService(Context.INPUT\u方法\u服务);
imm.showSoftInput(searchTextField,InputMethodManager.SHOW_强制) 请确保模拟器没有“硬件键盘存在”。尝试删除`InputMethodManager imm=(InputMethodManager)getSystemService(Context.INPUT\u方法\u服务);imm.showSoftInput(searchTextField,InputMethodManager.SHOW\u隐式)`@pietmau这对你使用模拟器没有帮助,对吗?@pietmau是的,模拟器你确定你的模拟器没有“硬件键盘存在”?你可以将这一行添加到manifest.xml android:WindowsofInputMode=“StateAllwaysVisible”你是在模拟器还是在设备上测试的?我是在模拟器上做的
<EditText
....
<requestFocus />
</EditText>
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(searchTextField, InputMethodManager.SHOW_FORCED); <-- change here.