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!
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.
将它放在您的活动清单中: android:windowSoftInputMode="stateHidden"
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();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.