【发布时间】:2018-08-31 12:48:34
【问题描述】:
我知道这个问题被问了很多次,但我尝试了几种建议的解决方案,但都没有按预期工作。
我有一个 EditText 在我启动该活动时打开键盘,如何阻止它启动键盘。
//Solutions I have tried thus far
//Solution 1
//XML
android:editable ="false" <!--is deprecated & does not work-->
//Solution 2
//XML
android:focusable="false" <!--Can no longer use the EditText -->
//Solution 3
//JAVA
editText.setinputType(InputType.TYPE_NULL); // Works but I can no longer use the edit text to add input
//Solution 4 - Similar to Solution 2
editText.setInputType(0); // Works but I can no longer use the edit text to add input
//Solution 5
//Using InputMethodManager
InputMethodManager imm = (InputMethodManager)getSystemService(INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(editText.getWindowToken(),0); //Does not work
【问题讨论】:
-
在 Activity 下的 Manifest 中添加
android:windowSoftInputMode="stateHidden"。
标签: android input android-edittext keyboard