How to instantiate an Activity with EditText fields without being automatically selected?

1

Developing an Android application, I came across a problem, I have an Activity where there are EditText fields in the xml, and when I instantiate it, the first EditText field is selected and the keyboard appears to fill, and I do not I wanted the keyboard to appear, and I did not select the field automatically, basically by setting up an initial Activity equal to the Evernote app login. And if you have how you pass the schemas to do that Activity with the TabLayout, ViewPager, and the parallax that it does best.

    
asked by anonymous 30.10.2015 / 18:15

3 answers

1

Change the focus to your Layout, as in the example below, taken from SOen :

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/mainLayout"
    android:descendantFocusability="beforeDescendants"
    android:focusableInTouchMode="true" >
    
30.10.2015 / 18:26
3

A simple way is to AndroidManifest.xml declare the activity this way:

<activity android:name=".MainActivity"
          .....
          android:windowSoftInputMode="stateHidden"
          >
    
30.10.2015 / 18:30
2

By default the android always marks the input with <autofocus/> or the first one, a solution is in onCreate insert the following excerpt:

InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(seuInputText.getWindowToken(), 0);
    
30.10.2015 / 18:26