3

This is my layout:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<TextView
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_centerVertical="true"
    android:text="Introduzca codigo de comercial"
    android:textAppearance="?android:attr/textAppearanceLarge" />

<ImageView
    android:id="@+id/imageView1"
    android:layout_width="400dp"
    android:layout_height="190dp"
    android:layout_above="@+id/textView1"
    android:layout_centerHorizontal="true"
    android:layout_marginBottom="60dp"
    android:src="@drawable/logo" />

<EditText
    android:id="@+id/textocontrasena"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_below="@+id/textView1"
    android:layout_marginTop="30dp"
    android:ems="5" >
</EditText>

<Button
    android:id="@+id/loginlogin"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_below="@+id/textocontrasena"
    android:layout_marginTop="20dp"
    android:background="@drawable/xmlbotonzarko"
    android:text="Login"
    android:textColor="#FFF"
    android:textSize="19sp"
    android:textStyle="bold" />

My problem is that the softkeyboard is opening automatically when I enter on the Activity. What I want is the softkeyboard to open just when the user clicks on the EditText(not before).

Thanks!

zapotec
  • 2,628
  • 4
  • 31
  • 53

3 Answers3

2

Edit your Activity code in your Android Manifest that is associated with this layout by adding either:

android:configChanges="keyboardHidden|orientation"

or,

android:windowSoftInputMode="stateHidden"

so that it would look something like:

<activity
    android:name="my.package.name.MyActivity"
    android:label="MyActivity"
    android:configChanges="keyboardHidden|orientation"  <!-- Pick one of -->
    android:windowSoftInputMode="stateHidden" />        <!-- these two   -->

This should prevent the softkeyboard from automatically opening up on activity start.

Mxyk
  • 10,678
  • 16
  • 57
  • 76
1

Place this inside the manifest for your activity: android:windowSoftInputMode="stateHidden"

K_Anas
  • 31,226
  • 9
  • 68
  • 81
0

put the focus on another view, and try to add this for your TextEdit View android:focusable="true" android:focusableInTouchMode="true"

Example change focus : ((yourView)findViewById(R.id.your_id)).requestFocus();

koleanu
  • 495
  • 5
  • 20