Reputation: 12352
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?
Upvotes: 2
Views: 3726
Reputation: 1706
Here's a possibility:
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
You can also find more possibilities in this topic.
Upvotes: 1
Reputation: 2945
The initial state of the keyboard is configurable in your Android manifest, like this:
<activity
android:name=".MainActivity"
android:windowSoftInputMode="stateHidden"/>
Upvotes: 7
Reputation: 134664
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.
Upvotes: 0
Reputation: 4199
Use
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(myEditText.getWindowToken(), 0);
In your code. See: Close/hide the Android Soft Keyboard
Upvotes: 0