[英]how do you make it so the Android keyboard doesnt open up when the user opens up my app?
你能做到吗,所以当你打开应用程序时,只有当你点击其中一个editText时,屏幕上的键盘才会打开吗?
In order to hide the virtual keyboard, you can use the InputMethodManager like this (you can put it in the onCreate()
method of your landing activity) : 为了隐藏虚拟键盘,您可以像这样使用InputMethodManager (您可以将其放在登陆活动的
onCreate()
方法中):
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(myEditText.getWindowToken(), 0);
Add the following code in onCreate method of your activity: 在您的活动的onCreate方法中添加以下代码:
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
It did the trick for me :) 它对我有用:)
在AndroidManifest.xml中设置android:configChanges =“ keyboardHidden”
it is up to your requirement. 这取决于您的要求。 For suppose if you want to hide the keyboard every time the user opens your activity, then you can add
android:windowSoftInputMode="stateAlwaysHidden"
in your android manifest for your activity. 假设您想在用户每次打开活动时都隐藏键盘,则可以在Android清单中为活动添加
android:windowSoftInputMode="stateAlwaysHidden"
。 If you want it dynamically then you can make change whenever event to close the keyboard occurs using 如果您希望动态地进行更改,则可以在发生关闭键盘事件时进行更改,方法是使用
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(myEditText.getWindowToken(), 0);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.