2

I have an edittext in my layout, like this:

//...    
<EditText
    android:id="@+id/editText_username"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:hint="@string/string_username" >
</EditText>
//...

And when the layout is shown, the keyboard appears with the focus on the edittext, but this just happens in ICS... And I don't want that the keyboard appears automatically, just when the edittext is clicked.

How can I do this?

hsz
  • 148,279
  • 62
  • 259
  • 315
amp
  • 11,754
  • 18
  • 77
  • 133

4 Answers4

7

The initial state of the keyboard is configurable in your Android manifest, like this:

<activity
android:name=".MainActivity"
android:windowSoftInputMode="stateHidden"/>
Phillip Fitzsimmons
  • 2,915
  • 2
  • 21
  • 20
1

Here's a possibility:

getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);

You can also find more possibilities in this topic.

Community
  • 1
  • 1
Jeje Doudou
  • 1,707
  • 1
  • 16
  • 24
0

Use

    InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(myEditText.getWindowToken(), 0);

In your code. See: Close/hide the Android Soft Keyboard

Community
  • 1
  • 1
Thkru
  • 4,218
  • 2
  • 18
  • 37
0

Check this answer. Basically, just add android:windowSoftInputMode="stateHidden" to your Activity in the manifest. This will cause the keyboard to be hidden when the Activity is launched.

Community
  • 1
  • 1
Kevin Coppock
  • 133,643
  • 45
  • 263
  • 274