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
  • 143,040
  • 58
  • 252
  • 308
amp
  • 10,768
  • 17
  • 72
  • 124

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,855
  • 2
  • 20
  • 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,662
  • 1
  • 16
  • 22
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,178
  • 2
  • 17
  • 36
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
  • 131,356
  • 43
  • 258
  • 273