在一个Android应用程序,只要该活动启动后,文本框获得焦点和软键盘会自动弹出。我曾尝试通过使用onCreate方法以下行停止,但它不能正常工作。
((InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE))hideSoftInputFromWindow(EditText.getWindowToken(),0);
解决方案
我知道这是旧的,但也许这将帮助别人的未来......
我还没有见过任何人提出stateHidden
从Android文档 - 安卓windowSoftInputMode
您清单文件看起来像:
<活动
...
机器人:windowSoftInputMode =stateHidden | adjustResize
...
>
In an Android app, whenever the activity launches, the textbox gets the focus and the soft keyboard pops up automatically. I have tried to stop this by using following line in onCreate method, but it does not work.
((InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE)).hideSoftInputFromWindow(EditText.getWindowToken(), 0);
解决方案
I know this is old but maybe it will help someone in the future...
I haven't seen anyone suggest "stateHidden"
From the Android docs - android:windowSoftInputMode
Your manifest file would look like:
<activity
...
android:windowSoftInputMode="stateHidden|adjustResize"
...
>