[英]SoftKeyboard on EditText
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).
我想要的是当用户点击EditText(而不是之前)时打开的软键盘。
Thanks! 谢谢!
Edit your Activity
code in your Android Manifest
that is associated with this layout by adding either: 通过添加以下任一项来编辑与此布局关联的
Android Manifest
中的Activity
代码:
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"
把焦点放在另一个视图上,并尝试为你的TextEdit添加这个视图
android:focusable="true" android:focusableInTouchMode="true"
Example change focus : ((yourView)findViewById(R.id.your_id)).requestFocus(); 示例更改焦点:((yourView)findViewById(R.id.your_id))。requestFocus();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.