2

これは私のレイアウトです:

<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" />

私の問題は、アクティビティに入るとソフトキーボードが自動的に開くことです。私が欲しいのは、ユーザーが EditText をクリックしたときにソフトキーボードが開くことです(前ではありません)。

ありがとう!

4

3 に答える 3

2

次のいずれかを追加して、このレイアウトに関連付けられているのActivityコードを編集します。Android Manifest

android:configChanges="keyboardHidden|orientation"

また、

android:windowSoftInputMode="stateHidden"

次のようになります。

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

これにより、アクティビティの開始時にソフトキーボードが自動的に開くのを防ぐことができます。

于 2012-07-27T11:51:46.240 に答える
1

アクティビティのマニフェスト内にこれを配置します。android:windowSoftInputMode="stateHidden"

于 2012-07-27T11:56:01.557 に答える
0

別のビューにフォーカスを置き、これを TextEdit ビューに追加してみてくださいandroid:focusable="true" android:focusableInTouchMode="true"

フォーカスの変更例: ((yourView)findViewById(R.id.your_id)).requestFocus();

于 2012-07-27T12:26:16.170 に答える