I have a TableLayout that I am dynamically adding content to in code in OnCreate. Once the Activity creates, it is focusing on one of my dynamically created EditTexts and displaying the keyboard. I don't want the keyboard to display until the user specifically presses one of the EditTexts. I've tried:
InputMethodManager input = (InputMethodManager) GetSystemService(InputMethodService);
input.HideSoftInputFromWindow(CurrentFocus.WindowToken, 0);
But the keyboard still displays and CurrentFocus returns null. So when I attempt to specifically point the focus to another view and then perform the above like:
InputMethodManager input = (InputMethodManager) GetSystemService(InputMethodService);
title.FindFocus();
input.HideSoftInputFromWindow(CurrentFocus.WindowToken, 0);
CurrentFocus is still null and the keyboard still displays. title is a TextView that I already have an instance of in code. Can I just not give focus to a TextView or is there something else I'm missing?
Hiding the Soft Keyboard Programmatically You can force Android to hide the virtual keyboard using the InputMethodManager, calling hideSoftInputFromWindow, passing in the token of the window containing your edit field. This will force the keyboard to be hidden in all situations.
setShowSoftInputOnFocus(false); to disable the software keyboard showing when the EditText is touched. the hideKeyboard(this); call in OnCreate to forcible hide the software keyboard.
You can force Android to hide the virtual keyboard using the InputMethodManager, calling hideSoftInputFromWindow , passing in the token of the window containing your focused view. This will force the keyboard to be hidden in all situations. In some cases you will want to pass in InputMethodManager.
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
AndroidManifest.xml
fileandroid:windowSoftInputMode="stateHidden"
For example:
<activity
android:name=".package.example.MyActivity"
android:windowSoftInputMode="stateHidden"/>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With