Do not open keyboard automatically when you enter screen with EditText

7

I have a screen with a EditText ai whenever I enter it already open the keyboard. I wanted to just open the keyboard when I clicked on it.

I tried this but the keyboard is not opening at all:

mItemDescriptionTextView.setFocusable(false);
    
asked by anonymous 13.08.2015 / 00:24

5 answers

2

To solve this problem open the file AndroidManifest.xml, then in the declaration of your activity add the following line:

android:configChanges="keyboardHidden|orientation|screenSize"

What will prevent the keyboard from appearing when the activity is created is keyboardHidden .

Example:

<activity
    android:name="com.example.activity.MainActivity"
    android:configChanges="keyboardHidden|orientation|screenSize"
    android:label="@string/app_name" >
</activity>
    
12.09.2015 / 21:28
9

You need to add android:windowSoftInputMode="stateHidden" within your AndroidManifest.xml :

<activity 
    android:name=".SuaActivity"
    android:windowSoftInputMode="stateHidden"/>

This flag will hide the keyboard when the user enters their Activity (even if EditText has focus).

    
13.08.2015 / 00:53
1

You can also create a method to hide the keyboard when you want, for example:

public void hideKeyboard(View v) {
    InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
}
    
13.08.2015 / 15:36
0

Use these attributes in XML:

android:focusable="true"
android:focusableInTouchMode="true"
    
13.08.2015 / 02:05
0

Use these attributes in your XML where this EditText is, I could only use putting those attributes inside a LinearLayout as below:

<LinearLayout          
        android:focusable="true"
        android:focusableInTouchMode="true" />
    
13.08.2015 / 17:02