0

Android アプリに問題があります: 次のように新しい Intend を開始すると:

Intent i = new Intent(MyFirstActivity.this, MySecondActivity.class);
startActivity(i);

Android は、 が表示されるMySecondActivityとキーボードを開きますが、その理由はわかりません。

これを無効にする方法は?

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

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/LinearLayout1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    tools:context=".MySecondActivity" >

    <Button
        android:id="@+id/foo"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="@string/edit" />

    <ScrollView
        android:id="@+id/scrollView1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

        <LinearLayout
            android:id="@+id/LinearLayout2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical" >

            <EditText
                android:id="@+id/editTextBemerkung"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:ems="10"
                android:enabled="false"
                android:hint="@string/bemerkung" />

            <AutoCompleteTextView
                android:id="@+id/editText1"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:ems="10"
                android:enabled="false"
                android:hint="@string/foo" />

            <Button
                android:id="@+id/foo2"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="@string/foo"
                android:visibility="gone" />

            <ImageView
                android:id="@+id/imageViewFoto2"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_gravity="center"
                android:contentDescription="@string/foto"
                android:src="@drawable/ic_launcher"
                android:visibility="gone" />

            <TextView
                android:id="@+id/textViewAnzahl"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/anzahl" />

            <TextView
                android:id="@+id/foo3"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/foo" />

            <TextView
                android:id="@+id/foo4"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/foo" />

            <AutoCompleteTextView
                android:id="@+id/foo6"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:ems="10"
                android:enabled="false"
                android:hint="@string/foo" />

            <AutoCompleteTextView
                android:id="@+id/foo7"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:ems="10"
                android:enabled="false"
                android:hint="@string/foo" />

            <TextView
                android:id="@+id/foo8"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/foo" />

            <CheckBox
                android:id="@+id/foo9"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:enabled="false"
                android:text="@string/foo" />

        </LinearLayout>
    </ScrollView>

</LinearLayout>
4

2 に答える 2

1

フォーカスされている編集テキスト/フォーカス可能な入力がある場合、キーボードが開きます。そのビューのレイアウト xml で次を使用します。

android:focusable="false"
android:focusableInTouchMode="false"

したがって、次のようになります。

<EditText
    android:id="@+id/editTextBemerkung"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:ems="10"
    android:enabled="false"
    android:hint="@string/bemerkung"
    android:focusable="false"
    android:focusableInTouchMode="false" />

お役に立てれば!!

于 2013-04-09T19:07:58.753 に答える
0

述べたように、これは開始EditText時に集中しているためである可能性が最も高いため、別のことに集中したり、追加したりできます。ActivityView

android:windowSoftInputMode="stateHidden

あなたの<activity>タグにmanifest。これにより、クリックするまでキーボードが非表示になります。EditText

これらのドキュメントの下部には、キーボードを扱うときに役立つその他の属性がいくつかあります。

于 2013-04-09T19:14:25.017 に答える