0

I am using galaxy tab with Android 3.1, I am trying to start activity with EditText inside its layout file, but the problem is that each time I enter the activity the keyboard is automatically shown. I don't want the keyboard to be shown except when I click the EditText.

I used many solutions, all of them worked for many android devices except my Galaxy Tab.

Amt87
  • 5,305
  • 4
  • 31
  • 51

2 Answers2

3

Set the following to your activity inside AndroidManifest.xml

android:windowSoftInputMode="stateHidden"

Or in onCreate of your activity's code:

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

Or try adding the following to your onResume()

try {
    InputMethodManager inputManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    inputManager.hideSoftInputFromWindow(this.getCurrentFocus().getWindowToken(), 0);
}
catch (Exception e) { /* do nothing */ }

For more info, read this

Community
  • 1
  • 1
waqaslam
  • 66,380
  • 16
  • 161
  • 174
  • is it a problem only with a specific model of galaxy tab? did you try any other tablet? – waqaslam Oct 16 '12 at 07:13
  • Yes it is as I mentioned above, actually I didn't use another tablet, also the edited answer by you has been used, thank you for your prompt response but unfortunately I don't know what is the problem – Amt87 Oct 16 '12 at 08:21
  • 1
    then it seems to be a problem with that specific version of ROM in your tab – waqaslam Oct 16 '12 at 08:50
1

In your AndroidManifest.xml:

<activity android:name="com.your.package.ActivityName"
          android:windowSoftInputMode="stateHidden"  />

More details about windowSoftInputMode can be found here.

This setting will hide soft keyboard when user enters new Activity (even if EditText control gains the focus). Soft keyboard will be shown only when user clicks the edit box control.

Ram kiran Pachigolla
  • 20,647
  • 14
  • 56
  • 74