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
  • 136,835
  • 55
  • 236
  • 297
amp
  • 9,710
  • 15
  • 67
  • 118

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,715
  • 2
  • 19
  • 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,644
  • 1
  • 16
  • 20
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,128
  • 2
  • 16
  • 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
  • 128,402
  • 43
  • 252
  • 270