Hide soft entry in OnCreate

I have a TableLayout that I dynamically add content to code in OnCreate. Once the Activity creates, it focuses on one of my dynamically created EditTexts and displays the keyboard. I do not want the keyboard to appear until the user clicks on one of the EditTexts. I tried:

InputMethodManager input = (InputMethodManager) GetSystemService(InputMethodService);
input.HideSoftInputFromWindow(CurrentFocus.WindowToken, 0);

But the keyboard is still displayed, and CurrentFocus returns null. Therefore, when I try to specifically point the focus to another view, and then do the above:

InputMethodManager input = (InputMethodManager) GetSystemService(InputMethodService);
title.FindFocus();
input.HideSoftInputFromWindow(CurrentFocus.WindowToken, 0);

CurrentFocus is still zero, and the keyboard is still displayed. title is a TextView in which I already have a code instance. Can I just not focus on the TextView or is there something else that I am missing?

+5
source
2
    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
+22

  • AndroidManifest.xml
  • : android:windowSoftInputMode="stateHidden"

:

<activity
         android:name=".package.example.MyActivity"
            android:windowSoftInputMode="stateHidden"/>
+6

All Articles